{"id":697,"date":"2023-11-13T23:31:23","date_gmt":"2023-11-13T22:31:23","guid":{"rendered":"https:\/\/www.sevenwatt.com\/main\/?p=697"},"modified":"2023-11-13T23:34:56","modified_gmt":"2023-11-13T22:34:56","slug":"ford-nugget-linbus-part-2-hardware-and-ide","status":"publish","type":"post","link":"https:\/\/www.sevenwatt.com\/main\/ford-nugget-linbus-part-2-hardware-and-ide\/","title":{"rendered":"Ford Nugget LINBUS &#8211; part 2: Hardware and IDE"},"content":{"rendered":"\n<p>An Heltec ESP32 module with OLED screen was chosen for the ease of having a (tiny) OLED screen besides the standard capabilities of Wifi and Bluetooth connection and a USB interface for easy programming. An Heltec 32 Wifi Lora V3 was used. In this project I don&#8217;t expect to use the Lora radio.&nbsp;<\/p>\n<p>To interface the 3.3V based microcontroller to the harsh +11V to +16V car environment, a dedicated LINBUS interface using the TJA1021 chip was selected. This takes care of all the level shifting between the voltages and splits the one-wire LIN bus into a two-wire standard serial interface TX\/RX. The LIN-BUS&lt;-&gt;UART board can be found on amazon or from Chinese webshops.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/Nugget-LINBUS-schema.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"468\" src=\"https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/Nugget-LINBUS-schema-1024x468.png\" alt=\"\" class=\"wp-image-698\" srcset=\"https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/Nugget-LINBUS-schema-1024x468.png 1024w, https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/Nugget-LINBUS-schema-300x137.png 300w, https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/Nugget-LINBUS-schema-768x351.png 768w, https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/Nugget-LINBUS-schema.png 1199w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>&nbsp;<\/p>\n<p>Currently a standard DC jack 5.5\/21.mm is connected to the the LIN-interface voor the power supply and the blue LIN bus wire connects to an available LIN bus spade connector behind the campervan-side batteries of the Nugget. The ESP32 is powered through a USB cable. Eventually when making a more permanent design it can powered form the car battery side with an additional DC\/DC convertor.<\/p>\n\n\n\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-ad2f72ca wp-block-group-is-layout-flex\">\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-ad2f72ca wp-block-group-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/IMG_7585-1-rotated.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"480\" height=\"640\" src=\"https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/IMG_7585-1-rotated.jpg\" alt=\"\" class=\"wp-image-701\" srcset=\"https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/IMG_7585-1-rotated.jpg 480w, https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/IMG_7585-1-225x300.jpg 225w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/IMG_7589-1-rotated.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"480\" height=\"640\" src=\"https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/IMG_7589-1-rotated.jpg\" alt=\"\" class=\"wp-image-702\" srcset=\"https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/IMG_7589-1-rotated.jpg 480w, https:\/\/www.sevenwatt.com\/main\/wp-content\/uploads\/2023\/11\/IMG_7589-1-225x300.jpg 225w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><\/figure>\n<\/div>\n\n\n\n<p>\u00a0<\/p>\n<p>As Software Development Environment I use Visual Studio Code and the PlatformIO plugins. Within PlatformIO I make use of the Arduino framework for ESP32 and installed the ESP32 and Heltec libraries. The latter for OLED support. The code will eventually end up at github.\u00a0<\/p>\n<p>An introduction to coding and programming the ESP32 is beyond the scope of this post. Many good tutorials can be found, for example those:<\/p>\n<p><a href=\"https:\/\/docs.platformio.org\/en\/latest\/tutorials\/index.html\">PlatformIO tutorials<\/a> or\u00a0<a href=\"https:\/\/randomnerdtutorials.com\/vs-code-platformio-ide-esp32-esp8266-arduino\/\">Random Nerds Tutorials<\/a><\/p>\n<p>To interface with the LIN bus I forked two repositories of <a href=\"https:\/\/github.com\/mestrode\">Mestrode<\/a>. The first is a library to drive the dedicated functions of the TJA1021, and the second is the generic implementation of the LIN bus protocol using a serial interface of the ESP32. Both I had to fork as I needed to extend them. The transceiver library was using hard-coded TX\/RX pins and for the Heltec board those pins were occupied by other functions. And for the interface library there was no spy-mode reading function implemented. I need to listen-only to the bus, while it is not in sleep mode. A new frame can come at any moment.<\/p>\n<p><a href=\"https:\/\/github.com\/SevenW\/Lin-Transceiver-Library\">https:\/\/github.com\/SevenW\/Lin-Transceiver-Library<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/SevenW\/Lin-Interface-Library\">https:\/\/github.com\/SevenW\/Lin-Interface-Library<\/a><\/p>\n\n\n\n<blockquote>\n<p>The actual code is not pushed to github yet.<\/p>\n<\/blockquote>\n\n\n","protected":false},"excerpt":{"rendered":"<p>An Heltec ESP32 module with OLED screen was chosen for the ease of having a (tiny) OLED screen besides the standard capabilities of Wifi and Bluetooth connection and a USB interface for easy programming. An Heltec 32 Wifi Lora V3 was used. In this project I don&#8217;t expect to use the Lora radio.&nbsp; To interface [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[79,80,78],"tags":[77,74,73],"class_list":["post-697","post","type-post","status-publish","format-standard","hentry","category-esp32","category-ford-nugget","category-linbus","tag-esp32","tag-ford-nugget","tag-linbus"],"_links":{"self":[{"href":"https:\/\/www.sevenwatt.com\/main\/wp-json\/wp\/v2\/posts\/697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sevenwatt.com\/main\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sevenwatt.com\/main\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sevenwatt.com\/main\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sevenwatt.com\/main\/wp-json\/wp\/v2\/comments?post=697"}],"version-history":[{"count":4,"href":"https:\/\/www.sevenwatt.com\/main\/wp-json\/wp\/v2\/posts\/697\/revisions"}],"predecessor-version":[{"id":707,"href":"https:\/\/www.sevenwatt.com\/main\/wp-json\/wp\/v2\/posts\/697\/revisions\/707"}],"wp:attachment":[{"href":"https:\/\/www.sevenwatt.com\/main\/wp-json\/wp\/v2\/media?parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sevenwatt.com\/main\/wp-json\/wp\/v2\/categories?post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sevenwatt.com\/main\/wp-json\/wp\/v2\/tags?post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}