CH340 with custom baud rate for Diesel Heater and Raspberry Pi - usbserial

Is there a way (or trick) to set a CH340 to 25000 baud on Linux?
If not:
Is there a better chip which is able to do that 25000 baud (no FTDI please)?
Is there a completely different and better way to achieve my goal (see below)?
Background:
I would like to interface a China Diesel heater to a Raspberry Pi (OpenPlotter on a ship).
This was done in Open Source with a uC (STM or EsP32) with http://www.mrjones.id.au/afterburner/
There is this blue wire with half duplex RS232#TTL and baud rate of 25.000 baud (8N1). This is the binary, proprietary communication interface to the heating.
I tried to use one of this china USB to RS485 adapters which use a CH340C internally.
The interface of Afterburner:
The USB to RS485 interface is similar Afterburner:
I think I should be able to use this interface without major modifications if I would use "channel B" of RS485 with a pull up resistor (worth a try).
My main problem is the baud rate at the moment. I think I will run in the same problem if I would use a CP210x. I guess a FTDI232 might be able to handle this baud rate but I will not use this chip at all.
My other idea was to use a NodeMCU (CH340 with ESP32/ESP8266) and speak 25000 baud to the heating and 28800 over the serial to USB of the NodeMCU. I think this is a little bit overkill to do it this way.

Related

Using consumer cellphones to build a mesh network for IOT devices?

I have been looking into LoRaWAN for a low cost waterproof asset tracker I am looking at building.
AFAIK, the primary benefits of LoraWAN over say LTE-M or cellular are: no connectivity costs and potentially lower power consumption.
What I'm wondering is: why can't we use our own cellphones as the "base station" that the IOT device talks with? We can do this with bluetooth and WiFi, why not cell? Is it the LTE protocol that prevents it? Physics? What am I missing?
There's quite a few architectural reasons why Peer-to-Peer LTE isn't feasible, but the largest is probably the fact that in LTE the uplink and downlink use different modulation techniques.
In the downlink (the connection from the Base stations (eNodeBs) to the User Equipment (our mobile phones)) Orthogonal Frequency Division Multiplex (OFDMA) is used, this means the phone listens out onto the RF interface for the OFDMA signal.
This works well, OFDMA is a great way of encoding the data onto the air interface, but it has a very high peak-to-average-power ratio, this means if the UEs used OFDMA in the Uplink (From the UE to the eNodeB) they'd have awful battery life.
Instead in the Uplink LTE uses Single Carrier Frequency Division Multiple Access (SC-FDMA), which is much more power efficient and allows you talk all day, so the eNodeBs listen on their RF interface for the SC-FDMA modulated traffic.
This means our UEs (Mobile phones) use one type of modulation to send and a different modulation scheme to receive, so they can't talk directly to one another as they can't send OFDMA modulated data, only receive & visa-versa.
Some more reading on OFDMA & SC-FDMA.
The LTE relay interface inducted as part of Release 10 allows the deployment of relay nodes (a kind of low cost eNB) that are fixed and that use in-band LTE to extend the coverage of standard eNodeBs by one hop, improve signal quality and to increase the network capacity. Relays can be placed such that it converts the long single hop into two shorter hops.
However the approach of using UE seems have many challenges as it can make UE to get bit loaded with more functional changes across layers(MAC, PHY, RRC, NAS) as it has to take additional functionalities from Relay nodes/eNB as well ranging from lower layer signalling, co-ordination, mobility to forwarding. Also, there might be additional power consumption and change in antenna to support the same which all will add to more cost of UE.

NodeMCU ESP8266 WiFi low RF power level

I tested the NodeMCU firmware on 4 ESP8266 modules and I have a problem with the WiFi range of the modules (only 8 meters).
I tried to switch to the Arduino ESP8266 core firmware and voilĂ , the modules have a better range (>12 meters). I think that NodeMCU doesn't set the ESP8266 to the maximum power.
I looked at the Arduino code and it contains a setOutputPower method that set the RF power level of the ESP8266. How can I set this option in the NodeMCU firmware without modifying the firmware?
Higher RF power level means higher power consumption obviously. You need to balance your options should you run the device off a battery.
NodeMCU offers wifi.setphymode() to control this. The documentation gives you a nice overview how the pyh mode relates to typical power consumption.
Update 2017-11-19
There's a PR in the making that'll give you control over system_phy_set_max_tpw from the SDK: https://github.com/nodemcu/nodemcu-firmware/pull/2171

Read 8n2 serial with 88us break and 2 bit MAB (250000 baud) (DMX512) from ESP8266

How do i configure the serial port on a ESP8266 to accept DMX? I have found some arduino libraries that does this, but they require a 16MHz processor (the ESP-8266 will be run at 80 or 160MHz)
I don't know specifically about the Arduino but provided you can set the baud rate 44K or greater that should get you adequate resolution to read all the bits(4us), MAB(8us) and BREAK(88us).
However Gooding ESP8266 it looks like a WiFi Module for the Arduino. If this is the case are do you actually want to receive Art-Net or sACN via the TCP/IP stack?
Additionally If you are looking to receive DMX, because it's RS485 (Differential pair) you will either need to configure the Arduino for RS485 or (in a pinch, or short cable run) use the positive and Ground to a 422 Receiver, though it might work it's not the best practice and it likely won't be reliable.

Send data from PC to Raspberry

I'm wondering if I can do something like this:
Do some image processing with opencv on my pc, do some math and send data to RaspberyPi to PID controller and then control servos, in real time.
UART wolud be the best connection?
In principle you can use any means to communicate from the PC to the Raspberry PI that are available (UART, ethernet, etc.).
However, you just have to be careful about any time requirements you have in the system you are controlling and check whether the communication rate is suitable.
For instance, you can use 9600 baud UART to temperature control, as the dynamics of such systems are usually slow. If your servos control an inverted pendulum, then the communication speed might make it impossible to control.

Need help using Arduino R3 as serial-to-usb converter (to program something)

I have researched (and learnt quite a bit), but I have little experience in programming and only really understand basic sketches so far. I would like to use the Arduino R3 (more specifically, the usb to serial converter chip) to program a full-size hobby radio.
I have connected my radio to the Arduino appropriately (5V, Rx, Tx, Gnd) and put the Arduino into Tristate mode (apparently you have to do this..), but I seem to be lacking appropriate drivers. I basically want my Arduino R3 to function exactly like this: CP2102 . Please note that I am not being super cheap. To get something like that where I live would take at the very least a month. Some people also say that I should remove the Atmega chip. The ultimate goal is that I have a device, with drivers, on a com port and not just an "unknown device".
So, my questions are: leave the Atmega on, or remove it? and which drivers do I need?
Thanks!
EDIT: I found almost exactly what I need just after I posted. For some reason I couldn't get it to work, but maybe you could help me understand? Here's the link LINK If anyone is keen to help me out!
Just to make it clear: it has been done before, but I get the feeling people leave out things which they think are obvious, but to the not-yet-professional tinkerer like me aren't :/
Thanks so much!
It seems like the links you reference are for older Arduinos with an FTDI chip. The Arduino Uno doesn't use that. Here's a link for using the Uno
So! All of the older Arduinos (NG, Diecimila and Duemilanove) have
used an FTDI chip (the FT232RL) to convert the TTL serial from the
Arduino chip (Atmel ATmega). This allows for printable debugging,
connecting to software like PureData/Max, Processing, Python, etc.
etc. It also allows updating the firmware via the serial bootloader.
The good news about the FT232RL has royalty-free drivers and pretty
much just works. The bad news is that it can -only- act as a
USB/Serial port. It can't act like a keyboard, mouse, disk drive, MIDI
device, etc.
and
The Arduino Uno has a number of facilities for communicating with a
computer, another Arduino, or other microcontrollers. The ATmega328
provides UART TTL (5V) serial communication, which is available on
digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels
this serial communication over USB and appears as a virtual com port
to software on the computer. The '16U2 firmware uses the standard USB
COM drivers, and no external driver is needed. However, on Windows, a
.inf file is required. The Arduino software includes a serial monitor
which allows simple textual data to be sent to and from the Arduino
board. The RX and TX LEDs on the board will flash when data is being
transmitted via the USB-to-serial chip and USB connection to the
computer (but not for serial communication on pins 0 and 1).
Basically the LINK you provided, shows the user HACKING the Arduino. Using the USB/Serial(TTL) converter(what ever chip that is on your Arduino) to link to the Radio's Mini Din connector, in place of connecting to the Arduino's CPU.
As stated in other answer the Arduino uses a CHIP (of some flavor) to bridge the USB(Virtual Serial Port) to the Serial Port of the ATmega328 micro. These pins are available on the Shields connector 0(RX) and 1(TX). Hence you see the picture wiring those pins to the Radio's DIN connector.
Where I would expect in addition the RESET of the Arduino's CPU would be held to GND, this would force the pins into Hi. Simply with an extra wire jump the RESET pin to a GND.
It's working! Somewhere along the line the drivers for my arduino seem to have been deleted, so I reinstalled them, did what you said, and learnt something.
So to clarify for others: pretty much plug and play (as the link I posted suggests), but make sure to install the arduino drivers properly.
Thanks a lot for the help!

Resources