Both hardware and software implementations
'How to connect pins to the espruino board?'
Below heading "Choosing pins"
'You can find out which pins to use by looking at your board's reference page and searching for pins with the UART/USART markers'
Remember to cross Tx ==> Rx
You migth also find this helpful:
Using a logic analyzer will greatly improve the learning experience as may be seen reviewing these images with the embedded protocol decoders:
Ok, so I checked Pixl.js documentation.
I didn't get anything maybe I am just dumb.
According to Pinout https://www.espruino.com/Pixl.js#pinout of Pixl.js, there is a Note:
"Pixl.js has one available I2C, SPI and USART (and infinite software SPI and I2C). Unlike other Espruino boards, these peripherals can be used on any pin."
However, I also found additional information when I put my mouse cursor on these "!" two descriptions on D0 and D1 pins:
D0 - "Serial Console RX when Bluetooth is disconnected"
D1 - "Serial Console RX when Bluetooth is disconnected"
Moreover, "Purple boxes" show pins that are used for other functionality on the board. You should avoid using these unless you know that the marked device is not used.
I don't see "Purple Boxes, I see "Purple circles" on the PCB layout https://www.espruino.com/Pixl.js#pinout
Further below there are "Purple boxes" with "Pins not on connectors.
H0 3.3v LCD
H1 3.3v BTN1
H2 3.3v BTN2
H3 3.3v BTN3
H4 3.3v BTN4
H5 3.3v LCD
H6 3.3v LCD
H7 3.3v LCD
H8 3.3v ! LCD
H9 3.3v LCD
In conclusion I have a few pins rs-232 cables 2,3,5,7,8 ready and no idea where to put them in pixl.js
'I don't see purble boxes, I see "Purple circles" ' (sic purble)
See beneath heading:
'Pins not on connectors'
I see our posts crossed
Thank you for your help.
I am looking at Pixl.js reference board and also on my Pixl.js but I can't find any pin labelled /marked as UART/USART marker.
Is there a possibility to meet with you on Discord or on Signal teleconference ? I have noticed you have experience with GPS programming
While it doesn't appear there is a RS-232 module built
and it would take some digging to see if the onboard hardware UART could be used without the RS-232 handshaking CTS/RST, (maybe with software timers/timeout) it certainly would be possible to write a simple software equivalent using any of the pins described. (note: you may [should] need a level shifter - don't remember RS-232 output voltages)
Certainly there must be a common ground, Tx==>Rx, Rx==>Tx and depending on software both RTS and CST to initiate the handshaking. So, three, four or five connections. Chose a pin for each and set the mode for each pin first.
If not well versed in RS-232 comm, creating one would be fun and a tremendous learning experience and made much easier using the post #3 logic analyzer described above.
'but I can't find any pin labelled /marked as UART/USART marker.'
the schematic might provide some assistance:
found below the tutorial image icons beneath heading Information
You actually mentioned the Tx/Rx reference D0 and D1 in post #4
'Ok, so I checked Pixl.js documentation. I didn't get anything'
I'll agree that the docs (diagrams for hardware SPI/I2C/USART) are more suited for the STM family, the earlier Espruinos, when the Nordic nRF micros came about, it did take me some time to grasp software SPI/I2C/USART as it can be used on any pin. I'd re-read over the USART link in post #2 and just stick with it. There are plenty of examples and tutorials.
Remember: should you use the hardware USART the Pixl will have to give up B.T. comm which shares that Serial port
Thank you for your huge help,
I am optimistic and 2,3,5 should work!
Thank you also for pinMode https://www.espruino.com/Reference#l__global_pinMode and 'modules' link, https://www.espruino.com/modules/
both are great,
now I found js codes
Just did some digging, and it will be imperative to watch those voltages:
Voltage dividers and level shifters are very likely to be required. I'd even consider opto-isolation as a better alternative as a dual chip is well under $1 USD
and a complete solution using a standard RS-232 cable:
SparkFun RS232 Shifter - SMD
Which cables can be used to solder them? Do they have any name?
'Which cables can be used to solder them? Do they have any name?'
Standard RS-232 cables have the thumb screw sub-D connectors - no soldering required.
@bart Hold your horses before you destroy your Pixle...
RS-232 is -12V +12V line voltage and that is way beyond what any processor can handle except you put som drivers/receivers in between.
I could read nothing specific about the RS-232 in Novatel Flexpack6 specs that would say different, also because the connectors look like classic RS-232 9 pin (25 pin) D-connector.
I expect that you have to use a level converter / adapter with a chip like the MAX3232 - Datasheet.
This is for full control. To get started with just receiving date, you may get away with some simpler setup... which of course would need some bread boarding...
For basic understanding about RS-232: https://www.maximintegrated.com/en/design/technical-documents/tutorials/8/83.html and there is also the wikipedia page https://en.wikipedia.org/wiki/RS-232
But that does not help you much directly... so I whipped this up:
(1.) 'Tame' 12V signal down to 3V with resistors / voltage divider:
` :+12V >-----//-------. : | : | : | : | : | : | : | : R2 .-. : 5.6k | | : '-' : | : +---------------------> +3V (+2.92V 'exact') : | --- safe for 0..3.3V input : R1 .-. still good enough to be : 1.8k | | detected as logical 1 : '-' : | :0V GND --+-//-------+-----------------+---- 0V GND : | | : ----- ----- : --- --- : - - `
The voltage divider of 5.6k Ohm and 1.8k Ohm takes the +12V down into the safe zone of 0..3.3V but still high enough - +2.92V - to be detected as a logical 1.
(2.) Checking what this voltage divider does 'to us' when the signal switches to -12V:
` : .-----------------> -3V (-2.92V 'exact') : | --- kills 0..3.3V input : | : | : | : | :0V GND --+-//-------+---(------------+----- 0V GND : | | | | : ----- R1 .-. | ----- : --- | | | --- : - '-' | - : | | : +---' <--- -3V (-2.92V 'exact') : | : R2 .-. : | | : '-' : | : | : | : | : | : | : | :-12V >-----//-------' `
The same way the divider worked for positive voltages, it works for negative ones, which means we end up with -2.92V, way below the safe zone for a 0..3.3V input, and it will kill 'us'.
(3.) A simple solution to prevent the -12V coming thru and reusing part of the existing voltage divider:
add a diode in forward direction in to the input:
` : .-----------------> 0V : | : | : | : | : | :0V GND --+-//-------+---(------------+----- 0V GND : | | | | : ----- R1 .-. | ----- : --- | | | --- : - '-' | - : | | : +---' : | : R2 .-. : | | : '-' : | : | : | : --+-- : / \ : '---' : | :-12V >-----//-------' `
The diode blocks the current flow and resistor R1 makes no the output line a 'solid' 0V / GND, detected as a logical 0.
(4.) Verify the new circuit with +12V:
` :+12V >-----//-------. : | : .---, : \ / : --+-- : | : o <----- 11.5...11.3V : | : R2 .-. : 5.6k | | : '-' : | : +---------------------> +3V (+2.80..+2.75V exact) : | ---------- still good enough : R1 .-. to be detected as : 1.8k | | logical 1 : '-' : | :0V GND --+-//-------+-----------------+---- 0V GND : | | : ----- ----- : --- --- : - - `
The diode now lets current pass. It passes though for a price: a voltage drop of theoretical 0.7V for a readily available Silicon (SE) diode, such as an 1N4148 or alike, (vs 0.2V of a today less used Germanium (GE) diode. GE was first detected and applied for semiconductors). I said theoretical, because the drop is also current dependent and is less for very low currents... Almost any switching diode will do. Calculated 'new' voltage at the input pin for the processor is now 2.80..275V, still good enough for a solid logic 1 detection.
To understand a schematic, it is helpful to think of the 'text' line - position on the vertical matches the voltage. This is especially helpful to immediately understand what a voltage divider does. In our case we have to make it a 4:1, and since 'the 1 part is included in the 4 parts' - think of a gallon jar filled by 4 quarts reduced to 1, like 12V to 3V, the resistors are 3:1... and with the E-series values, 5.6k and 1.8k get us there... the values were chosen to put a load of about 1.6mA, well in the safe zone, and with a short line (symbolized as // ) , it is stable enough. I expected the GPS is really delivering -12/-12V on the lines..., if it is less, the divider resistances have to be adjusted.
This help with the GPS TX line connected to the Pixle RX pin (the pin you define for your serial or is defined with the serial you pick).
Then, of course, GND goes to GND.
Now, that the GPS device sends, may require a few other connections to be in place. The null-modem description - such as the wikipedia one: https://en.wikipedia.org/wiki/Null_modem - gives it away. It also depends on the flow control. Since above circuitry works only from reading signals from GSP and no sending, flow control is not really an option. Similar, almost a simple, adaptors you can build to send signals to GPS with a Transistor and resistors.
The whole RS-232 was introduced to transmit digital data over a simple 2-wire phone line with the technology available an affordable end of the 50' / early 60'. Beside the two digital devices, usually a RS-232 Terminal - CRT Monitor display and keyboard - and the computer, two Modems were needed - one on both sides - to MOdulate a carrier frequency by the digital signal, then transmitted as audio / sound over the phone line, and on the other side DEModulated back to the digital signal. Since with a direct line, this is not needed... but to simulate the circuitry to satisfy the protocol conditions, a null-modem is used, that, for example the RX with the TX lines on one connector compared to the other connector. Since we miss some of the signals on the processor side, we can connect specific pins on the GPS side, so the GPS think the modem (connection() is ready to send and the other side is ready to receive.
I will try to work it out
To which Espruino devices I can solder pins and get data from rs232 port
I'm going to decode NMEA data from external GPS/GNSS receiver (it is a Novatel Flexpak6 RS-232 DB9)
Which Espruino Board can I use to read and store rs232 data (it is ASCII format NMEA, ?
How to connect pins to the espruino board?
There is no power on the pinout of Novatel's rs232 com1 port as follows
1 COM1_RTS/422TX- 8
2 COM1_TXD/422TX+ 2
3 COM1_RXD/422RX+ 3
4 COM1_CTS/422RX- 7
11,14 Ground 5
I want to grab some data from rs232, use that data for GPS position computation, and I want to store data and export it from espruino board.
Which equipment do you suggest?