Author Topic: Sending data from Arduino to ESP8266  (Read 3950 times)

0 Members and 1 Guest are viewing this topic.

Offline 2slow4meTopic starter

  • Newbie
  • Posts: 9
  • Country: cs
Sending data from Arduino to ESP8266
« on: October 06, 2017, 02:25:46 am »
Hey guys, got a quick question. Now, last time i asked how to use the CC3000 module, and most people said "go to ESP8266" so i did. Now, i want to do the following: my Arduino collects sensor measurements (float Temperature, float Pressure, float Humidity), and i want to send them over UART to ESP8266 and receive them so that i can send them on dweet. Now, you might ask yourself "Why don't you just connect the sensor to the ESP?". Well, i'm planning on hooking an 16x2 LCD on the Arduino so i can relay the data there as well. Now, i've tried several codes for both the Arduino and the ESP, and all i keep getting on the ESP is junk ( 8 digit temperature in Celsius for example).

I tried:

1) Serial.print(temperature) on Arduino with Serial.read() on ESP = junk
2) Serial.write(temperature) on Arduino with Serial. read() on ESP = junk
3) Serial.write(lowbyte) +Serial.write(highbyte) with Serial.Read = junk

I assume there's something i'm doing wrong or missing, so i would need some help. I hope someone can provide some quick and easy code samples for me to try since i noticed ESP8266 (i have ESP-01 with the 8 pin in 4x2 layout version) are very common and a lot of people use them. Thanks in advance guys.
 

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 2587
  • Country: fr
    • kripton2035 schematics repository
Re: Sending data from Arduino to ESP8266
« Reply #1 on: October 06, 2017, 06:23:56 am »
on the esp8266, as there are almost no I/O available, the issue is to uns i2c everywhere.
so you can use one bmp250-280 barometric-temprature-humidity i2c sensor to get your values
then on the same, i2c bus, use an easy to find i2c to lcd module on ebay for around $1
so all your sensors will be connected directly to the esp8266, and no more fuzzing with the I/Os not available on the esp8266.
 

Offline 2slow4meTopic starter

  • Newbie
  • Posts: 9
  • Country: cs
Re: Sending data from Arduino to ESP8266
« Reply #2 on: October 06, 2017, 06:30:58 am »
The problem is delivery of any component to Serbia will take two weeks at least, and i have no such time. I barely found an ESP to borrow. id rather just find a way to use UART to send the data from Arduino to ESP. Basically, i want to send 3 integers to from Arduino to ESP. Im out of money (student, nearly spend all of my money, and with the border taxes which are here very random even on 1$ shipments, ) and out of time to complete my project, this is the solution which i feel will take me the least time.

I got the Arduino reading sensor data, and the ESP sending stuff to dweet, i just need to send the right stuff :)
 

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 2587
  • Country: fr
    • kripton2035 schematics repository
Re: Sending data from Arduino to ESP8266
« Reply #3 on: October 06, 2017, 09:00:18 am »
try to print something simple like "AAA" and see what comes to the rx port of the esp8266
may be it's only baud, or parity or ?
it should definitely work like that. it's only a software problem.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9946
  • Country: nz
Re: Sending data from Arduino to ESP8266
« Reply #4 on: October 06, 2017, 09:31:59 am »
its probably a clock issue, something isnt running at the speed you (or it) thinks it is.

Stick the arduino in a loop. 'count' 1 to 384.
Set the arduino baud rate to (count * 300)
Send a string with some text followed by (loop variable*300), eg first loop will be something like test1
add a delay of 100ms.

now watch for the data on esp to see if the string "test" ever appears in the junk data.
If it does, the number after test is the baud rate.

If you find this works then you can be sure that one of your devices has its clock setup wrong somewhere.

« Last Edit: October 06, 2017, 09:36:20 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline picandmix

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: Sending data from Arduino to ESP8266
« Reply #5 on: October 07, 2017, 08:01:32 pm »


I assume there's something i'm doing wrong or missing, so i would need some help. I hope someone can provide some quick and easy code samples for me to try since i noticed ESP8266 (i have ESP-01 with the 8 pin in 4x2 layout version) are very common and a lot of people use them.

Was in a similar situation some months ago looking to use the ESP 8266 with the Arduino Uno  but still to unable to find a straight forwards working example anywhere on the web, strange ?
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9946
  • Country: nz
Re: Sending data from Arduino to ESP8266
« Reply #6 on: October 08, 2017, 11:43:22 am »
i have some code here somewhere that allow flashing of a STM32 over wifi using the esp8266

custom windows reflashing app ----- WIFI network ----- ESP8266 ---- uart link ---- STM32 uart in boot mode

let me know if you want to see any of the code.

Now that i think about it, I have a vague recollection there was something a bit weird about getting the uart working.
Actually no, i remember what that was. it was getting the esp8266 into uart parity mode, which is required for stm32 bootloader.
So that isn't relevant to you
« Last Edit: October 08, 2017, 11:48:02 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
Re: Sending data from Arduino to ESP8266
« Reply #7 on: October 08, 2017, 11:47:24 am »
Be careful

Arduino is 5V, esp8266 is 3.3V and is obsolete. ( now esp32 take the place )


 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9946
  • Country: nz
Re: Sending data from Arduino to ESP8266
« Reply #8 on: October 08, 2017, 11:50:38 am »
Be careful

Arduino is 5V, esp8266 is 3.3V and is obsolete. ( now esp32 take the place )

Holy shit. i just looked at the specs of the ESP32. Wow.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 2587
  • Country: fr
    • kripton2035 schematics repository
Re: Sending data from Arduino to ESP8266
« Reply #9 on: October 08, 2017, 12:11:21 pm »


Quote from: ebclr on Today at 14:47:24
Be careful

Arduino is 5V, esp8266 is 3.3V and is obsolete. ( now esp32 take the place )


for me esp8266 is not obsolete. esp32 and esp8266 are two different chips, the esp32 is far superior, but we can do many projects with an esp8266. oh, and esp32 is 3.3v too.
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Sending data from Arduino to ESP8266
« Reply #10 on: October 10, 2017, 05:51:24 am »


Quote from: ebclr on Today at 14:47:24
Be careful

Arduino is 5V, esp8266 is 3.3V and is obsolete. ( now esp32 take the place )


for me esp8266 is not obsolete. esp32 and esp8266 are two different chips, the esp32 is far superior, but we can do many projects with an esp8266. oh, and esp32 is 3.3v too.

I would back ebclr up on this, the ESP8266 is obsolete. If I had some lying around for a project I would use them, but I wouldn't bother ordering any more for my bits box.

In fact I have just been shipped 5 of these: https://www.aliexpress.com/item/WEMOS-LOLIN32-Lite-V1-0-0-wifi-bluetooth-board-based-ESP-32-esp32-Rev1-MicroPython-4MB/32831394824.html

With the latest ESP32 revision, and a Lithium battery interface, 500mA Max charging current, onboard USB/serial interface, and less than US$5. You are saving only $2.50 using the ESP8266, and you can spend that much on a USB/Serial adapter.

Here's a table of the differences between the two:


(from https://www.cnx-software.com/2016/03/25/esp8266-and-esp32-differences-in-one-single-table/)
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 
The following users thanked this post: ebclr


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf