I always liked, and still do like, Arduino Due, with 84MHz available for 12$ from China.
Recently I stumbled over the Lolin module and ordered it for <10$:
Normally clocked at 80MHz, it seems to be possible to run at 160MHz and 240MHz as well. Most importantly, while there are many ways to program it, it can be just programmed via Arduino IDE as well:
For the low price it brings not only WiFi and Bluetooth, but has mounted a 128x64 OLED display as well:
Later maybe for streaming video from the airplane bottom mounted camera as well (on bigger, ILI9341 320x240 color LCD -- the videos are currently full HD and stored on SD card).
I thought this new Arduino might be of interest for others as well,
Hermann.
P.S:
The module has a dual core 32bit CPU, one core does WiFi, Bluetooth and other stuff, the second is for you only:
On OLED display I could read 887459712, which is correct modulo 2^32:
$ bc -q
(100000000*99999999/2)%(2^32)
887459712
1000/8.39
119
And I read 8.39 (ns per loop), which says that 119.000.000 loops per second can be computed, which is proof that CPU has >80MHz.
Now to WLAN far distance link quality between ESP32 and Pi Zero W, yesterday I was able to see 38/70 link quality (-72dBm) over a distance of 55m, and that inhouse!
Currently we are in youth hostel Friedrichshafen/Germany at Lake Constance, and I did measure the distance between Pi Zero W on one end of a very long floor and ESP 32 on the other end with Gmaps pedometer as 55m:
Here you can see the 38/70 and copied in 37/70 measurements I made at the other end of the floor on the ESP32 OLED display (zoom in to see the details):
So if inhouse 55m is possible, I hope for more distance possible outside with Pi Zero W flying with RC airplane, and ESP32 OLED displaying altimeter information on ground.
Now I describe the Arduino IDE code for ESP32, and the Raspberry Pi Zero W code.
The ESP32 starts as wireless access point (192.168.4.1) and waits for some computer to connect.
When Pi Zero W starts, it connects to that AP by these lines in WPA config:
I did install Apache webserver on the Pi, so that it serves "http://192.168.4.2/wifi" web page. This web page gets refreshed every second by this script started via /etc/rc.local:
The content of /var/www/html/wifi looks like this:
pi@raspberrypi05:~ $ cat /var/www/html/wifi
Quality=70/70
Signal level=-38 dBm
pi@raspberrypi05:~ $
OK, this was the Raspberry side, now the Arduino IDE code for the ESP32 with OLED.
The sketch is based on BasicHttpClient.ino, but instead of connecting to an AP, the ESP32 gets AP itself via WiFi.softAP(). After Pi Zero W connects to ESP32 AP, the loop() does GET requests to "http://192.168.4.2/wifi", and in case of success, draws the response on OLED. 16 point font is a little bit too large, but only leading "S" and trailing "m" are missing for 2nd line. The code relies on Pi Zero W becoming 192.168.4.2, which seems to always be the case. No idea whether this is always the case, or how to determine the Pi Zero W IP address on ESP32 side:
I had to remove all Serial output lines from BasicHttpClient.ino, because otherwise the sketch does not work without a laptop connected, which is needed for ground altimeter. A final test showed that ESP32 and Pi Zero W work fine just powered, ESP32 has to be started first so that Pi Zero W can connect to AP:
First let me say that I have no relationship to Espressif/ESP32 or the seller of that ESP32 OLED module or Raspberry. I am just thrilled of the inhouse Wifi working distance between ESP32 and Pi ZeroW, that is why I document what I found here. Find the new Arduino sketch for the new youtube video below:
As with a previous video where I walked the 55m youth hostel corridor and recorded ESP32 OLED display
the new OLED screen has an action indicator that shows each update in the sketch loop(). New is bottom right continuous display of clients connected to ESP32 AP (I tested with laptop connecting to the AP and 2 got displayed).
In Böblingen/Germany IBM lab we have >20 connected buildings, and I used the longest straight line basement corridor I could find. To my surprise the 170m (again measured with Gmaps pedometer) of that corridor were not enough to see any Wifi connectivity issues!
Link quality was in 30-33/70 range, and signal level was in -(77-80)dBm range!
(I always had the plan to use the very long straight basement corridors of IBM Böblingen lab, but the plan was to do so for max. speed measurements of my fast driving autonomous robots)
The airplane wheight did increase to 40.9g by the added BMP180 pressure sensor. The airplane was not able to fly high, and therefore I removed the bottom camera and screws, which reduced weight by 3.0g landing in range of previous weight. After the airplane did not climb more than 5m today, I did even remove the now unneeded camera ribbon cable and its tape. This reduced wheight by another 0.9g. Still no luck in getting airplane fly high. I assume that the GND/VCC/SCL/SDA connectors from BMP180 soldered on Pi ZeroW do too much harm to the airplane upswing, and that the Pi ZeroW needs to be mounted somewhere else, perhaps below the airplane. Will try when back home at end of he week:
P.S:
I used an endless loop python script with time.sleep(1) based on this article, started via /etc/rc.local, to determine altitude and provide via .../height URL:
I will provide the details when back home, interesting was that the (endless) python script always stopped 4 hours after startup. That is no problem since the Lipos will never hold for that time.
Below sketch might be useful as starter for both, Wifi processing as well as OLED display output. I learned from several sketches out there and combined what I needed. Multiple .addAP() calls allow the Lolin32 to work with several access points without recompile. And display.setLogBuffer(5,30) seems to be a nice alternative to Serial output. Sketch connects to Wifi AP, reports its IP address and then logs RSSI (Received Signal Strength Indicator) in a new line every second.
I had problems to take a focused photo of OLED with my Android cameras, only fuzzy photos. So I used PS3 Eye as webcam. Same problem with that in both settings of its adjustable fixed focus zoom lens. Then I learned that I can manually set focus continuously and so I got this photo I wanted:
I made one ESP32 the AP, and the other connect to it. Best signal strength (-10dBm) happens when placing both antennas side by side.
I placed the ESP32 acting as AP on window sill in 1st floor of our house and moved with the 2nd connected to the AP far away outdoor. I got RSSI values (updated each second on OLED) even at 200m distance (with few trees in line of sight), connection dropped at 208m distance. These long distances don't make much sense though since I did not test sending data sofar. And signal strength was in the high -80s and low -90s dBm range which makes functionality unlikely, see table here:
After power cycling, the sketch on mobile ESP32 tried to connect to AP, and I walked back on the field direction our house. It was able to connect to AP and display its IP address on the OLED at distance 168m, but again with signal strength in the -80s dBm range. I walked further back direction house until signal level was -70dBm (with a small tree in line of sight). The distance to AP on window sill at that point was 87m.
Will use advanced sketches to transfer data (over HTTP request) for investigating how far reliable packet delivery is possible. And will move the AP ESP32 (battery/Lipo powered) on the field as well for direct line of sight connection long distance measurements.
As the table pointed to indicates, anything more than -70dBm should not be considered. I tested on distances with around -75dBm and every 20th-30th request is slow (>1000ms), but successful.
I built a 1-URL Web server and access point on one Lolin ESP32, and a HTTP Client on 2nd, you can find sketches below.
It turned out that I got best connectivity if ESP32 Wifi antennas pointing up and the ESP32s point to each other. This shows where I took the measurements yesterday evening, web server and access point on window sill of my secondary living place, HTTP client on rail of Schönbuchbahn:
The first number is millisecond time to send GET request and receive response. The 2nd (negative) number is RSSI connectivity, and the number after '#' is a 0-2 conter value received from web server. The RSSI value was always 69-70 (I watched 600 requests) without any slow, all requests take <70ms, "middle" always <55ms, distance was 58m in this case:
Hermann.
1-URL Web server and access point:
/*
* access point & 1-URL HTTP server (http://192.168.4.1/foobar)
*/
#include <WiFi.h>
#include "SSD1306.h"
SSD1306 display(0x3c, 5, 4);
WiFiServer server(80);
char req[]={'G','E','T',' ','/','f','o','o','b','a','r',' '};
char plain[]="HTTP/1.1 200 OK\nContent-type:text/plain\n\n";
int c=0;
#define N 3
void setup() {
display.init();
display.flipScreenVertically();
display.setContrast(255);
display.setLogBuffer(5, 30);
WiFi.softAP("ESP32_TestAP", "esp32example");
display.clear();
display.println("AP");
display.drawLogBuffer(0, 0);
display.display();
server.begin();
}
void loop(){
WiFiClient client = server.available();
if (client) {
int i=0;
while (client.connected() && i<sizeof(req)) {
if (client.available()) {
if (req[i] != client.read())
break;
++i;
}
}
display.clear();
if (i==sizeof(req)) {
while (client.connected() && client.available())
client.read();
if (client.connected()) {
client.print(plain);
client.print(c % N);
display.print(".");
} else {
display.print("@");
}
} else {
display.print("#");
}
if (c++ % N == N-1)
display.println();
display.drawLogBuffer(0, 0);
display.display();
client.stop();
}
delay(100);
}
Wow, saw video to this code in action with >200fps on 2.4" OLED display. The display dimension was same as for the Lolin OLED (128x64). I wanted to try, but had no MPU6050 at hand here in secondary living place. So I just deleted all MPU calls, added missing variable definitions and fixed OLED pin numbers, see small diff below. I awaited to see a fixed view display, but to my surprise a complete 3D movie got displayed with >300fps! Maximum reported was 334fps:
4
As always I had problems with focus of my Android phone camera, but you get the idea on how this looks.
Here is a 8s 720p youtube video I took:
Because bitlash works for AVR processors only, it is not an option for ESP32.
I was guided to the solution for ESP32 debug shell on esp32.org forum.
Micropython allows to read/write GPIO pins, set direction and even access OLED with few commands: Micropython as debug shell for ESP32 (and its OLED) - ESP32 Forum
Micropython can be flashed with two esptool.py commands, and easily used with "screen /dev/ttyUSB0 115200". Of course I will do normal programming of the ESP32 module with Arduino IDE -- I will use Micropython for debugging only, eg. after soldering.
P.S:
I just learned how Arduino IDE Blink Example sketch looks like in Micropython:
import machine, time
pin12 = machine.Pin(12, machine.Pin.OUT)
while True:
pin12.value(1)
time.sleep(1)
pin12.value(0)
time.sleep(1)
I got help and made much progress, now it is easily possible to debug+dev the ESP32 board mobile wireless in Android JuiceSSH telnet session (who needs a laptop for that?). Details can be found in this posting, the MicroPython version I used is attached to that posting:
MicroPython is cool on its own (I was able to let boot.py connect to Android AP, start Telnet and FTP server, and do initial OLED screen). Especially it allows you to start jobs on both of the ESP32 240MHz cores.
Currently I will continue to program that module via Arduino IDE though. Only if I need a (wireless) debug session (eg. after soldering) I will flash that MicroPython in between for debugging.
OK, now I want to use the ESP32 module to control 12V motors and soldered male headers to the module.
Without any change I powered the module, and the boot display from last posting appeared.
Next I enabled wireless hotspot on my Android, and after 2 seconds the ESP32 was shown as connected.
Next I connected to the wireless Android AP from my laptop and did "telnet 192.168.43.128" into the ESP32 (I got the ESP32 IP address from Android as described here):
$ telnet 192.168.43.128
Trying 192.168.43.128...
Connected to 192.168.43.128.
Escape character is '^]'.
MicroPython ESP32_LoBo_v2.0.8 - 2017-11-04 on ESP32 board with ESP32
Login as: micro
Password:
Login succeeded!
Type "help()" for more information.
>>>
After having verified voltages on 5V, GND and 3V3 pins I skipped RX/TX and connected to pin 15.
This simple code verified that I did solder pin 15 correctly:
While even 3.4V from Lipo are enough to power a Pi Zero, 3.8V did not make Lolin ESP32 module boot.
So I remembered that I have a Polulu 5V step-up converter
and decided to create a female/male micro USB plugin between ESP32 module and Lipo micro USB connector I already had. And it works, from the 5.09V generated by step up converter when not connected to ESP32 module I can measure 4.77V between GND and 5V pins of ESP32 module when connected as in this photo:
I did connect two unidirectional MOSFETs that were mounted on robot already to the three 1500rpm gear motors (two back wheels are controlled from same MOSFET). I could have used the Lipo for powering the ESP32 module, but for testing cable was fine for me.
This is wireless test start (robot is jacked on Lego platform):
Login succeeded!
Type "help()" for more information.
>>> p12 = machine.Pin(12); pwm12 = machine.PWM(p12); pwm12.duty(0)
>>> p13 = machine.Pin(13); pwm13 = machine.PWM(p13); pwm13.duty(0)
>>> pwm12.duty(512)
>>> pwm12.duty(0)
Unidirectional motor controller is OK for two back wheels, but steering wheel motor will need a bidirectional controller:
P.S:
This robot already has weight 533g, and Raspberry Pi Zero with camera for high framerate (≥180fps) video processing is yet missing ...
P.P.S:
"So this is kind of another level of debugging, not single pins anymore, but motor functionality."
I wanted to use a (Bluetooth) BLE remote gamepad to controll the robot ESP32 module:
But I found out that (Bluetooth) BLE support is unlikely to be available in ESP32 MicroPython or ESP32 Arduino IDE in the near future.
Then I wanted to use the other ESP32+Oled module I had to connect an Arduino joystick and send telnet commands to the MicroPython on robot ESP32 module in order to be able to remotely control the robot. But this time my soldering was bad and I killed the 2nd ESP32 module Immediately after that I did order 2 new ESP32+Oled modules with free shipping for <10$ each from banggood.com (because there shipping time is only 7-20 days).
Next I remembered that I do have two Wemos D1 modules (ESP8266 in Arduino Uno form factor):
While waiting for the new ESP32+Oleds modules I decided to give the D1 modules a try (did cost 6.50$ with free shipping two years ago, now 3.50$). Most important thing I had to remember was to use "D5" in sketch instead of "5" for Arduino pin D5 ...
First I installed a temperature and humidity sensor in a location of interest in our house and connected to a D1 module over 3m of three thin cables. I only modified one function of "Examples->ESP8266WebServer->HelloServer" and used DHT11 library for the sensor:
Surprisingly easy, now I have my 1st IOT device in our house, and it refreshes every 5 seconds in browser:
DHT11, OK, 66.00% r.F. 18.90°C [16381020]
(r.F. is German for r.H. or relative humidity).
Now I try to get "Examples->Ethernet(esp8266)->TelnetClient" to connect to robot ESP32 module wirelessly for robot remote control.
Bad news first on the steering omni wheel robot. I played with telnet commands "right()" and "sbrake()" with maximal speed "pwmb.duty(1023)". While the robot turned quite fast on carpet, I tried on floor tiles and the results was really bad. Turning on floor tile without moving forward just does not work well (unclear whether it is as bad with moving forward).
Then I tried to run robot "blind" across big free space in our living room. And that with maximal forward speed, timed and with full brake after one second:
Braking distance was something in 5-15cm range only. And the robot had to accelerate from stand still. Despite that the robot moved 10 tiles forward and 4 tiles to the right, with 31.5cm tile lenght. This demonstrated an average robot forward speed of 3.4m/s of >12km/h already!!
$ bc -ql
sqrt(10^2+4^2)*0.315
3.39265382849473753968
sqrt(10^2+4^2)*0.315*3.6
12.21355378258105514284
All three motors are 12V 1500rpm gear motors, back wheel diameter is 65mm ➫ in theory 5.10m/s maximal robot forward speed:
$ echo "pi=4*a(1); 1500/60*pi*0.065" | bc -ql
5.10508806208341401246
$
I recently bought and recieved a Wemos Lolin32 OLED Module board. It took me a lot of effort to put the little online documentation together but I got it all working.
Now it runs a little webserver with DS18B20 temperature server. It displays the startup proces on the display and at the end of the startup proces it displayes the associated accespoint and IP-adres. On the little internal website I got the ability to read the temperature and operate the attached red power-led and green activity-led.
In the future I want to add UI cards with the temperature, access point, IP-adres, digital clock and analog clock.
While searching for information about the board I discovered this topic. It is nice to see the information about the board and DIY projects of others.
This pos got my attention:
mikerr:
I got some of these a while back, and keep one on my keychain as a ssid scanner, here's my code:
These sketches seems to be very usefull. Thank you for sharing! I definately will try them sometime!
One last thing: can anyone tell me whether it is possible to connect one or more buttons to this board? And if so: does the board have internal pullup or pulldown resistors? If not: what would be the steps to do this by my self.
At the moment I only have a little experience with a Teensy 2.0 which has internal pullups resistors and a nice Bounce library to nicely interact with momentary push buttons.