Category Archives: Arduino

Sharp PC-G850 Serial over WiFi Module

YAEP (Yet Another ESP Powered Project): An ESP8266-12 powered WiFi module for the Sharp Pocket Computer via the 11-pin connector connects wireless to PCs for transfer of programs and data.

The ESP8266 connects to your home WiFi or acts as an AP for initial configuration. The Serial port of the G850 becomes accessible via TCP on port 23. You can use telnet or netcat (nc) for simple direct transfers to/from the PC or use socat to create a virtual com port. The module supports 9600baud and shortens CTS/RTS and pulls these signals up to +5V, so you need to use XON for flow control.

Please note:

  • The G850 uses inverted serial protocol logic levels (i.e. logical “high” is represented by a “low” (0V) TTL level, logical “low” is represented by a 5V TTL level. The ESP8266 uses the SoftSerial library on GPIO 4 and 5, which supports inverted logic levels
  • Raw TCP is implemented without encryption on port 23. You can connect via telnet to receive or send data or programs but everyone on the same network can read the transferred data in clear text
  • The module does only support serial port communication (i.e. it does not emulate the CE-126 synchronous communication for print and cassette tape commands)
  • In the TEXT/Sio/Format menu enable 9600 baud, 8N1 and no flow-control. End-of-file “1A” allows the G850 to stop listening when receiving a file. You can still send files without the end-marker, but need to interrupt the “load” command by pressing “ON/BREAK”. The received text will be in the editor.
  • Sleep timeout can be set. The module starts blinking befor it goes to sleep and pressing the PRG button resets the sleep timout.
  • Some basic “AT” commands allow configuration changes without having to re-flash the module
Tex/Sio/Format menu

Why not Bluetooth? I started out using a HC-06 BT module, but learned along the way that this module is no longer supported by Windows 10’s BT stack. After several hours of fruitless tests, I gave up and resorted first to an ESP32. However, the BT stack that implements a serial port pushes even the most bare-bone program beyond 1MB in size (thank you Espressif), so I opted for raw TCP instead.

I have not noticed that the WiFi module decreases battery life dramatically, especially since I implemented deep-sleep.

WiFI Serial Module for Sharp PC-G850

The module is a double sided PCB. I isolation-routed it with FlatCAM. Top-side is very much limited to traces and the two buttons, all vias can be manufactured with just copper wire (i.e. no through-hole rivets required) and all pins only need soldering on the bottom-side. You can find the EAGLE files at the end of this post.

The module consists of a double sided 1.5mm PCB, an ESP8266-12, a 3.3V voltage regulator, a 6x 1K, 2 x 330Ohms, 1 x 1.5K, 1 x 3K3 SMD resistors (0805 type), a 100uF capacitor, 1x LED (0805) and a 90 degree 11-pin header. The G850 connector and the case are 3D printed.

Disclaimer: I am not an electrical engineer. These projects are a way for me to learn and figure out ways to overcome the problems I encounter. By all means, if you have suggestions for doing things better, please let me know.

You can reach me on twitter at @ChrisHerman if you need help.

ESP8266 module PCB and 3D printed 11-pin connector (bottom view, version 3)
Schematic, version 4 (.sch file available in resource section)

11-pin connector: A 3D part for the 11-pin connector which others may be able to re-use in their designs. The 2mm drill holes need to be positioned 200mil (5.08mm) above and below the connector and 100mil (2.54mm) in the orthogonal direction, away from the axis formed by the 11 pins (see picture below)

Sending and receiving files

To receive a file, plug-in the module (hostname of my module is G850V.local), type on the PC (OSX/Linux):

nc G850V.local 23>test.c

And on the G850 press TEXT, then S (for Sio) and S again (for Save).
Terminate nc with ^c on the PC

To send a file, first press TEXT, S (for Sio) and L (for load) on thje G850.
Then type on the PC:

nc G850V.local 23 <test.c

terminate nc with ^c on the PC

AT commands

Baudrate (1200..9600), WiFi settings and sleep timeout can be set via a small set of “+++AT+” commands. These commands can be sent from the G850 or via netcat ot telnet from your PC/Mac (of course, this will require your WiFi settings work). There’s also a “failsafe” configuration that can be selected when pressing the PRG button of the module for 5 sec:

+++AT+CFG?

+++AT+CFG={“rev”:1,”sleep”:60,”baud”:9600,”port”:23,”ssid”:”GUEST”,”wifipw”:”your_pw_here”,”host”:”G850V.local”,”otapw”:”myOTAPW”}

Example:
+++AT+CFG={“ssid”:”GUEST”,”wifipw”:”pw”}

this sets the SSID to “GUEST” and the wifi access point password to “pw”.

numeric configuration items:
rev: integer, referencing the version of the configuration. I recommend leaving at 1
sleep: seconds until unit goes into deep sleep
baud: baudrate for connection with G850 (600…9600)
port: TCP/IP port (use 23 for telnet compatibility)

string configuration items:
ssid: the ssid name of your wifi
wifipw: password of your wifi network
host: hostname for use when requesting an IP address
otapw: password for protrcting your ota passwords (use espota protocol)

+++AT+SAVE
Returns: OK
Saves current configuration as failsafe.ini to LittleFS Flash file system. Pressing the PRG button for longer than 5 sec will load failsafe.ini configuration and reboot. This allows you to recover from a messed-up config.ini (e.g. wrong wifi credentials).

+++AT+SLEEP
Returns: OK
Puts the adapter immediately into sleep. Pressing the RES button on the module will wake it up.
There is an issue with the ESP8266’s deep sleep behaviour, because regardless of all interrupt and wake-up sources being disabled, the

Resources (all in my github repository)

ESP32 LoRa GPS Range Tracker – Part 1

The outset

A few months ago, I installed a LoRa Gateway and I was able to talk a friend into setting up a second gateway. Both are connected the TheThingsNetwork.org.

The idea is to build cheap, simple sensors for all sorts of stuff (temperature, rain, wind, usage of the football goals) and place them around our village (garden, school, commons, etc.).

The problem

But we do not know the range of our gateways just yet. Of course, we could get in our car with a simple module and drive until we lose connectivity. But where is the fun in that?

So the plan is to build a GPS enabled LoRa module, that logs the signal strength and allows us to draw a heat map of LoRa coverage in our area. It should also allow us to test different antennas and understand better how they influence the range.

The solution

An ESP32 with LoRa and display was sitting in my drawer and I ordered a GPS/GLONASS module from AliExpress. Everything us assembled on an impromptu test rack, ready to e powered by a USB power bank.

 

(The big yellow knob is a rotary encoder)

Next Steps:

 

    • Get the GPS to work (fuGPS library)
    • Get the display to work (U8g2lib library)
    • Connect the rotary encoder
    • Implement a menu system for parameter editing and control (ArduinoMenu library)
    • Figure out how to derive meaningful signal strength data from the LoRa transceiver
    • Connect an SD Card reader and log GPS and LoRa data
    • Do some wardriving and create a heat map of the area

Wemos TTGO ESP8266 with 0.91 Inch OLED

Sites in China and eBay sell an ESP8266 module with 4MB flash and a build-in 0.91″ monochrome OLED display and a rechargeable battery port.

TTGO OTA Demo

Display

The display is a 128×32 pixel display connected via an SSD1306 controller.
It took me a while to figure out how to get the display to work – the Chinese sellers provide a rubbish demo script that uses the wrong pins for the I2C interface to the display controller.

The following pins and library combination works well:

U8g2 library: https://github.com/olikraus/u8g2
Data= pin 2
Clock= pin 14
Reset= pin 4

A demo program is available here: ESP8266_LCD_Demo

TTGO pinout

Drivers

As often, the board requires additional USB UART drivers.
I found suitable drivers for my Mac here – they also offer Windows and linux drivers:

https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

WiFi

The antenna gain seems to be quite poor – I noticed the module loses connection to my AP about at half the distance that my ESP8266-12 or ESP8266-01 modules tolerate.
I successfully managed to run OTA updatable code (see example).

 Layout

The board layout is a bit unfortunate as so far as the micro USB connector is mounted on the top, protruding in height above the display, which will not allow to mount the module flush against the top of a case.

Two buttons (reset and GPIO01) allow to invoke flash mode and reset the device, which comes in handy during development.

The pins are labelled both on the front and back side of the board.

TTGO frontTTGO back

Price

At time of writing, the board can be bought between $9 and $12 from Chinese sellers and for $15-$20 from Western distributors. The ones I bought came with a plastic box, a battery cable and connector and pin headers (not soldered)

 

 

Arduino Nano Eagle Library

This is based on Warren Brayshaw’s post here, which seems to have the A0-A7 lines reversed (compared with the Nano V3 . Maybe it once was correct for an earlier version of the Nano – I don’t know). The library below has been updated to be consistent with V3. The ICSP headers are not included, just the headers on the long sides of the nano board.Arduino_Nano_library

 

Download: CRE-Lib1.lbr