2

I have a weather project in which I have to measure the temperature and humidity (DHT22 sensor), the pressure, and other things, and then show them on a local web page (using a Wemos D1 R1) in either my phone or PC (I have both an Arduino Uno and a Wemos D1 R1 for this project)

I wanted to use only the Wemos D1 R1 since it works the same as an Arduino Uno except it has an ESP8266 WiFi built-in while the Arduino Uno doesn't, but as you may know it only has 1 analog pin while I need at least 3 or 4 analog pins, so in my case I should connect the sensors with the Arduino Uno and measure the temperature, humidity, etc. and then send those values to the Wemos D1 R1 which will show the results itself on a web page as I said earlier.

It seems that there is a way to do that using an I2C connection, but I have read many articles talking about connecting an Arduino to another Arduino using an I2C connection, but I don't know how to do that in my case (Arduino Uno and Wemos D1 R1); if there is another way to send values please tell me.

ocrdu
  • 1,795
  • 3
  • 12
  • 24
Anas
  • 21
  • 2

3 Answers3

2

As I see it, the most straight-forward way to connect 2 Arduinos is using their built-in UART (aka Serial port, TX/RX pins) communication.

There are many tutorials on this on Google, and a similar explanation can be found in this question: Serial communication arduino mega and D1 Wemos Mini

However, there is a slight difference. Arduino Mega has built in more than 1 hardware serial ports (I can't recall now if it's full 3 ports, or just 2), what leave one port for debug purposes, and the other - for your communication. In your case (Arduino Uno) - you have only one serial port, that if will be used for the inter-Arduinos communication - will not be available for debug/console messages. The solution for this is adding a Software Serial port, also highly available in tutorials over the net, here is one example: softwareserial between arduino uno and esp8266

Enjoy your project!

Offer
  • 107
  • 1
  • 11
2

I agree with @Offer that using UART is the simplest solution to connect the devices. I just want to suggest two alternatives:

  1. Use an external analog to digital converter IC. Using the Arduino only for analog conversion is a bit over powered. E.g. the ADS1115 has a resolution of 16 bits and there's already a library, so usage should be easy.

  2. The ESP8266's bigger brother - the ESP32 - has several ADC pins.

The biggest advantage (beside the higher resolution) is, that you only need to write code for one device, which makes your project less complex.

Sim Son
  • 1,878
  • 13
  • 21
0

Have a look at my blog 'Paynters Palace' and search for posts with the 'I2C' tag - you'll find quite a bit of useful code, I think.

This project shows how to connect two Arduinos using SPI

This project shows how to connect two Arduinos using I2C and how to pass arbitrary data types between the two units

starship15
  • 782
  • 4
  • 12