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.

4
  • 1
    You basically have the standard communication interfaces available: I2C, SPI or Serial (UART). You can freely choose between those, depending on your requirements. For I2C: You didn't describe, what exactly your problem is with doing this. Is it, that you didn't find a tutorial specifically describing the connection for Uno and Wemos d1 r1? Thats not really a problem, since codewise you can use any I2C code, that is aimed at the ESP8266 (which is the chip on the Wemos D1 r1). For the electrical connections: Just connect the corresponding pins (marked with SDA and SCL).
    – chrisl
    Apr 2, 2021 at 20:01
  • Yes, my problem is that unfortunately I did not find any tutorial out there showing how to do that! If there is a blog or a website showing how to do that please send it to me! otherwise for the electrical connections I only have to connect the arduino's ( the slave sender which is connected to the pc in the port usb directly in this case ) SDA and SCL pins to the wemos d1 SDA and SCL ( the master reciever )? what about the GND & 3.3V ( since it works on 3.3v not 5v) pin of the WeMos d1?
    – Anas
    Apr 2, 2021 at 20:11
  • DHT doesn"t use analog pins
    – Juraj
    Apr 3, 2021 at 5:45
  • You can use an analog multiplexer, greatly simplifies the code and only one micro.
    – Gil
    Apr 7, 2021 at 20:38

3 Answers 3

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!

1
  • Thank you <3 I will choose the I2C connection, So in my case I must work with 2 computers ( one connected with the slave sender which is Arduino Uno and the other one is master receiver which is WeMos d1 ) and the two board must be connected through i2c connection, my question is that can I work with only one computer which will be connected with UNO through the USB port and then send the values measured from the sensors to the WeMos? and if that possible sending me some code example will be much appreciated!
    – Anas
    Apr 3, 2021 at 8:54
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.

1
  • 1
    The external ADCs like ADS1115 are also much more precise than what Arduino Uno has, while cheap (less than 10 USD)
    – jpa
    Apr 3, 2021 at 4:52
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.