DEF Sensor Simulator – CanBed RP2040
Assembling a DEF Sensor Simulator Using a CanBed RP2040
Only basic electrical and DIY skills are required for the hardware assembly, however some basic soldering is needed to install the 4 pin connector. There are many YouTube videos that can teach you to solder. For delicate electronics such as this use a low wattage grounded soldering iron (25 – 30 Watts) to help prevent pad damage, don’t use a soldering gun.
The software installation in this procedure can be done from Windows or MacOS and is very easy.
Before you begin, please click here to read an important compatibility notice regarding the ECM (Electronic Control Module, aka Engine Computer) and info on compatible DEF head connectors.
If you run into difficulty post a comment at the bottom of this page.
Please read through all the instructions FIRST before beginning the project. There are web site links embedded in the instructions to help obtain parts.
NOTE: before mounting in the enclosure box, the CanBed needs to be programmed! Please see instructions in the Programming section for Windows and MacOS.
• Drill & bits
• Wire cutters / Strippers
• Small screw driver
• Ohm meter (multi-meter)
• Silicone sealant (optional)
• Soldering iron & solder
1) The CanBed RP2040 board can be obtained from several online sources. The suggested source is Digikey.com p/n: 1597-102991596-ND and ships from the USA.
2) You will need a USB cable with a micro USB connector, as the board does not come with one. They are available at online retailers or in many stores. This MUST be a fully connected cable, not just a charging cable.
3) Weather tight enclosure. The entire assembly of the CanBed RP2040 is very small. The larger enclosures used on the UNO or DUE variants will work just fine, although they are larger than needed. Feel free to get a smaller one if desired. Here is a smaller one from Amazon that will work ( as an added bonus this also has the gland nut).
4) The cable ( Spartan and PowerGlide chassis or any other using the DT-04 connector) and waterproof gland nut used on the DUE assembly can also be used with the CanBed RP2040. If a shorter cable with the DT-04 connector will work for your coach, here is one from eBay. If you have a Freightliner chassis refer to this post for the correct connector.
As an alternative to the “Gland nut” you can use a rubber grommet, which can be purchased from most hardware stores, such as ACE Hardware. Just get one that will fit your cable diameter. You could also just fill the hole in the box where the cable goes through with silicone sealant.
It is recommended that you program the CanBed RP2040 board before doing the assembly. Please refer to the Programming section at the end of this document.
Take the 1 Meter DT Extension cable that you purchased and cut the off the flat end with the exposed orange silicone as shown in the picture below, approximately 1 inch from the connector end ( if using the short cable from eBay, cut right where the wires enter the unneeded connector). The short end with the Orange silicone connector will not be used electrically, but if desired can be used as a “dust cap” for the DEF head sensor connector when the DSS is not in use.
After cutting the cable, trim back the outer jacket about 4 inches and expose the 4 inner conductors. Be careful to not nick the wires.
As mentioned at the beginning, the CanBed RP2040 needs to have a connector soldered to the board. The connector comes with the board. You can optionally directly solder the cable wires to the board if you wish. If you choose to solder the wires directly, you will need to feed the wires through the enclosure first, before soldering the wires to the board.
The wires associated with these pins (above picture) are connected to the CanBed RP2040 via the screw terminals. You will need to use an ohm meter (multi-meter) to determine which wire is connected to which pin, as the wire color codes are not standardized.
Strip about 3/16 inch of insulation off each wire end and connect to the screw terminals. Make sure the slot is fully open as shown in the picture below. If the wires are too large, you can trim off a few of the strands.
Insert the stripped wires into the slots shown in the picture below:
Tighten the screws to securely fasten the wires in the slots.
The finished board assembly can be secured in the box using Velcro. The smaller box will need one of the stand-offs in the bottom to be removed so the board will fit flat on the bottom OR the board can be mounted to the lid of the smaller box.
A completed assembly with smaller box:
NOTE: before mounting in the enclosure box, the CanBed RP2040 needs to be programmed! Please see instructions in the Programming section if this has not been completed.
Programming the CanBed RP2040 (Windows OS)
It is assumed that someone attempting to construct one will have a modest knowledge of a Windows based computer. The initial work was completed on a Windows 10 based machine, but it is expected that a Windows 7 or XP based machine will also work (USB drivers could be an issue). The computer will need to have at least 1 available USB 2/3 port.
The simulator software install file can be downloaded by clicking the download link below:
The file is usually downloaded to the “Download” directory on your Windows computer.
The download file (DEF_Sensor_Emulator_RP2040v1.ino.uf2) is a file that contains the compiled Arduino software appropriate for the CanBed RP2040 board. It is not necessary to install any additional software from Arduino or anywhere else.
1) Using a micro USB cable, connect the CanBed RP2040 board to your computer’s USB port. You should see a LED light up next to the micro USB port on the CanBed board. This indicates power to the board.
2) Open Windows File Explorer and find your download file (usually in the “Download” directory)
3) Right click on the download file name and choose “copy”.
4) Push and HOLD the reset button. While holding the reset button, push and HOLD the boot button. Release the reset button, wait about 3 seconds and then release the boot button.
5) A new Windows File Manger window should open. If one does not open, manually open File Manager and look for a new “drive” to be present and click on it.
6) Right click in location as indicated in the above picture and choose “paste”. This will copy the download file to the RP2040 board. When the file is copied, the File Manger window should close.
7) Wait about 5 seconds and then the LED below the reset button should begin to flash 2 times quickly and then the flash repeats. This is a good indicator that the board is working as expected. There are 2 LEDs to the right of the micro USB connector, labeled RX and TX. These 2 LEDS will probably be on solid (usually red in color).
8) Unplug the board from the USB port.
9) Programming is now finished.
Video after programming:
Programming the CanBed RP2040 (MacOS)
It is assumed that someone attempting to construct a DSS will have familiarity with a MacOS computer. The computer will need to have at least 1 available USB 2/3 port.
The simulator software install file can be downloaded by clicking the download link: Download File
The file is usually downloaded to the “Download” directory on your MacOS computer.
The download file (DEF_Sensor_Emulator_RP2040v1.ino.uf2) is a file that contains the compiled DSS software for the CANBed RP2040 board. It is not necessary to install any additional software.
1) Using a micro USB cable, connect the CANBed RP2040 board to your computer’s USB port. You should see the PWR LED light up next to the micro USB port on the CANBed board. This indicates power to the board.
2) Open Finder and navigate to directory containing the downloaded file (should be the “Downloads” directory)
3) Push and HOLD the BOOT button on the CANBed RP2040. While holding the BOOT button, push and release the RST (reset) button. You will see the CANBed RP2040 show up as an external disk. Once it shows up (a few seconds) you can release the BOOT button.
4) Within Finder, drag the DEF_Sensor_Emulator_RP2040v1.ino.uf2 file to the RP2040 disk (mine shows up as RPI-RP2, yours may be different). Once the file has been copied, the CANBed RP2040 will reboot and will not longer be displayed in Finder as an available disk. You will likely get a warning that the disk wasn’t properly ejected. This is normal.
5) Once the CANBed RP2040 has rebooted, the “LED” light will continuously flash 2 times and then there will be a slight pause. This is a good indicator that the board is working as expected. There are 2 LEDs to the right of the micro USB connector, labeled RX and TX. These 2 LEDS will probably be on solid (usually red in color) indicating that the board is not yet connected to a CAN Bus (ie. your coach).
6) Unplug the board from the USB port.
7) Programming is now finished.
The below animated gif shows the process of installing the DSS firmware to the CANBed 2040 board.
Connecting to your motorhome CAN network:
- Make sure that before you unplug your def head that the ignition is turned off, then unplug your def head. You may need to cut a zip tie to provide working slack in the wiring.
- Plug the simulator into the connection to your chassis wiring where the def head was plugged in.
- Turn on your ignition, some or all of the fault codes should go away and the Check Engine and MIL (Malfunction Indicator Lamp) lights should extinguish within a few minutes.
- If some codes remain, to clear your codes you will need to turn your ignition on (let all systems come up, about 20 seconds), then start your engine and fast idle for 5-6 minutes, shut down for 90 seconds, turn ignition on (wait for systems to boot 20 sec) start engine and fast idle for 5 min. You will do this a total of 3 times on the 4 cycle the codes should clear to the inactive status.
Note: on older engines or engines with older ECM software, some codes may not completely clear on their own. In this case code clearing intervention may be required. This is something that is still under study, see the Troubleshooting section for more info.