A microcontroller for Palm m100
After I build up the LiPo Palm m100, I knew, that I wanted to hook up a microcontroller to it. A relativity small one is the „D1 mini“. Of course, there are even smaller ones, but this one comes with a USB controller. So it is easy to program this microcontroller, even when it is already wired up.
Since the space in the m100 was already used by the charging components for the LiPo battery, the microcontroller and all required modules were placed outside the m100.
Needed for this modification:
- D1 mini microcontroller
- TTL ↔ RS232 converter
- 5V Voltage regulator (optional)
- 0.96" OLED Screen (optional)
- three mini switches (optional)
The first attempt was to connect the TX wire and RX wire of the m100 directly to the D1 mini. This wasn’t a good idea, since the output voltage are the RX/TX lines are nearly 12V, which can easily kill the D1 mini. So, I was extremely lucky, that the controller survived.
After connecting the wire directly, I hooked up a small oscilloscope, I saw the 12V problem:
In order to fix this problem, a TTL ↔ RS232 converter was used, which converted the 12V to around 3.3V, which the D1 mini can handle.
A second “mistake” was, that I connected the RX line of the m100 to the TX line of the D1 mini and vice versa. Since the RX and TX lines of the D1 mini are also used for the USB communication and uploading files, I soldered a switch in to disable the wires from the m100 while uploading a sketch to the D1 mini. Now I was able to upload sketches again, but debugging the sketch via the Serial Monitor of the Arduino IDE was still not possible. So the solution to this was simply using SoftwareSerial, which made the rx/tx-switches unnecessary.
Serial communication can be used with every GPIO pin of the D1 mini. Since a .96” OLED screen was used for simply outputting some text, the pin D4 is used as RX line and D3 as TX line. D2 is connected to the “Serial Clock Line” (SCL) of the Display and D1 to the “Serial Data Line” (SDA).
The used LDO for powering the Palm m100 is only capable of providing up to 200mA. Which can be critical when it is used for also powering the D1 mini and the OLED display. This is the reason why a 5V voltage regulator is used to convert the battery voltage to 5V. The used regulator has a wide input range from 0.8V to 5V and outputs in this range, always 5V, which then gets converted to 3.3 through the voltage regulator of the D1 mini. The setup is very power inefficient, because two regulators are used. It is better to convert the battery with a 1A LDO voltage directly to 3.3V and feed this voltage to the Palm and the D1 mini. This will be done in the near future. (But for prototyping it is good enough with two regulators.)
A third switch can be used for powering the 5V regulator, because the D1 mini will not be used the whole time.
Of course, everything needs to be connected to the same ground wire.
Next, the D1 mini needs some care. It should receive data from the Palm and display it on the attached OLED-display.
But there is not much needed, so the following script for the D1 mini is quite simple:
All the script does, is waiting for data on the "SoftwareSerial"-port and sends the data as String to the display.
And this is the complete setup...
(Still with wrong connection: RX needs to be switched with pin "D4" and TX with pin "D3"!)
… in action: