RS-485
Here we will log the development of RS-485 interface onto BoSL sensors.
Requirements:
- Upload Code
- Sleep/Wake sensors
- 3V3 5V interoperable
- Minimum wires
- Bus operation
Uploading code is the first issue to be addressed. RS-485 is half-duplex over a single twisted pair. This presents issues during uploading as it requires full duplex operation.
The easiest solution is to move to full duplex. This would require 2 twisted pairs thus a full bus likely 8. Ideally less wires would be needed.
Another solution is to modify the uploading program and use another wire to send to the sensor whether it should be receiving or sending data. This would likely require special programmer hardware and software.
It is also possible to update the Arduino bootload to recognise when it needs to be sending and receiving data. This may be possible, but it is uncertain how reliably this would work or if it is feasible.
Additional wires could also be left exposed on the sensors so that uploading remains possible via these. This solution is is difficult as it introduces another entry point for water.
A solution which looks promising is illustrated below. It is a 6 wire system. It enables uploading of code over half duplex RS-485 by utilizing the wake line for the programmer to receive data from the sensor. This allows for the full duplex needed while uploading. It should be noted that this system may have a hard time uploading over very very long cables as the TX from the sensor will not be over RS485. The exact length is yet to be determined however is likely in the range of 10s of meters.
This solution works because the use of TX and WKE are never needed simultaneously. That is that if the sensor is sleeping TX is not being used so WKE is free to be driven high to wake the ATmega. Conversely, when the sensor is being programmed it is already awake and so WKE signals do not need to be sent, freeing the line for TX.
A full list of wires is:
- 3V3
- GND
- RST
- WKE/TX
- RS-485 A
- RS-485 B
The option may also be available to use RST as a 5V rail. This is possible if the ATmega reset pin is 5V tolerant. On reading the data sheet it looks like a diode may be nessesary to protect the input pin.
https://au.element14.com/texas-instruments/sn65hvd75dgk/rs422-rs485-txrx-20mbps-3-6v-vssop/dp/3119111 This transceiver is looking promising. It has 5V tolerant inputs too!