B4R Question Uno with internet modules (ESP-01Wifi or Ethernet LAN)

Roger C

Active Member
Licensed User
Hi,

I'm trying to connect an Uno to network (and in near future a Nano also).
More or less like the schematic below with a WiFi-module.

As far as I understand, there is no library for Uno for connecting to a network?
There are a lot of examples in the forum for Ethernet and ESP8868 (the big board) but none of them works on this setup and especially not with Uno.

When powered up, I can access the AP and connect from my Android. I do an IP search and find both the mobile and this module. But when I try to connect to it with TCP Client in Android it doesn't work.

When bypassing Arduinos boot (with RESET to GND) I can access the board from my PC through the USB (with the module connected to pins 0 and 1) by using Arduinos Serial Monitor.
I can send AT-commands to the module... Or some at least. Querys with questionmarks doesn't work.
But still, it is alive.

I have found a lot of examples and librarys in C# but I can't program in C#.

In some threads I've seen references for using this module with SoftwareSerial but haven't found anything describing how it should work. The BT-example uses this but that was working by itself, Wifi needs more setup.

Anyone got this setup up and running?

To answer some questions right away:
- No I will not buy another board or get an Ethernet Shield. I have lots of Uno, Nano and Mega that I plan to use and also a lot of 8266 modules.
- This means I would really like to have a solution that works for Nano and Mega too.


Thanks in advance.
 

Cableguy

Expert
Licensed User
I would ditch the Uno and nano entirely.
The wemos D1 boards (esp8266 based) offers a lot more capabilities, more memory and integrated WiFi. Connecting a wemos to an android device is quite simple(r).
And, of course, you program it using our favourite soft B4R
 

MarkusR

Well-Known Member
Licensed User
the arduino ide have a SoftwareSerial library that you can use any other pins as serial communication.
More or less like the schematic below with a WiFi-module.
yes the tx to tx looks odd.
the serial0 at uno is also used for usb. maybe try the same with arduino mega and serial1.
i found this example project. (the circuit layout there is only for this (one of thousands) mentioned modul.)
https://create.arduino.cc/projecthub/jeffpar0721/add-wifi-to-arduino-uno-663b9e?f=1
this kind of wifi modul is on my wish list. currently i am happy with working bluetooth.
 

Roger C

Active Member
Licensed User
You can program the ESP8266 directly. It will be simpler.
Got that working. Can program it through USB-serial-converter and a terminalprogram. Also upload firmware.

I would ditch the Uno and nano entirely.
The wemos D1 boards (esp8266 based) offers a lot more capabilities
Does the WiFi in wemos work directly with the librarys r8266....?
Might look into them but still I have a lot of Uno, Nano and Megas. :)

There are a lot of libraries in Arduino.cc with the 8266-01 module (in C/C++ which I can't program) and I really want to get this working.
I can't really find a solution in B4R to do this in an easy way.

My wish is to have 10-60 satellites (like Nano or Wemos D1 mini), collecting data and also receiving commands to outputs. As a server there would be a RaspberryPi or a single-card-PC.
Satellites should be very small and connected through WiFi or Ethernet depending of placement.
Some will be placed in a metalbox under trains traveling 200km/h.

I can program the Uno with sensors, OLED-screens, inputs/outputs, Bluetooth,...
But I don't understand the Ethernet/WiFi-part. I really don't. I've been stuck for two weeks and reading everything on the net about it. If I understood C/C++ it might be easier but I don't...

I've ordered some Wemos D1 Mini now but that doesn't solve the WiFi-part really.

Anyone has a project they want to share in B4R and B4A/B4J with a client/server-application based on SoftwareSerial? Connecting the 8266-01-module to two pins and receving/transmitting data that way.
 

derez

Expert
Licensed User
I use softserial with Uno and ESP8266 where the ESP calls and get time from the net and pass the data to the Uno for display on TFT shield.
The Uno code (just lines):
B4X:
Private softserial As SoftwareSerial

softserial.Initialize(57600, 0, 1)
astream.Initialize(softserial.Stream, "astream_newdata", Null)

Sub astream_newdata (Buffer() As Byte
    Dim be(8) As Object
    Dim data(8) As Object = ser.ConvertBytesToArray(Buffer,be)
The use of pins 0,1 is not recommended because you can't debug it with the connection on, so if you have other pins - use other. I had to use them because of the shield.

For ESP:
B4X:
Private ustream As AsyncStreams
Private softserial As SoftwareSerial

softserial.Initialize(57600, D1.D6,D1.D7)
ustream.Initialize(softserial.Stream, "ustream_newdata", Null)

buffer = ser.ConvertArrayToBytes(Array (day,month,year,hour,minute,second,DayOfTheWeek, light))
ustream.Write(buffer)

Sub ustream_NewData (Buffer() As Byte)
    Log(Buffer)
End Sub
 
Top