Motorcycle tire temperature sensor with Arduino, MLX90614 and OLED i2c

 

 

The reason

It is safer to know that your tires are up to a temperature where you can lean the bike or brake and not end on the pavement. For race track days this is something you must have as the pressure in your tire must be changed during the day in order to have your tire up to the specified temperature where you can avoid cold tire wear or to hot tire wear.

Inspirational speech

This can be a fast project as I spent the time to learn how the components communicate with the Arduino and you will go through a fast lane. If you don’t know anything about Arduino, you will see it is easy. If you already work with Arduino it will be just a walk in the park.

Components

I am using an Arduino Nano V3 an OLED i2c screen, a voltage regulator and two MLX90614 infra-red sensors. All this stuff can be bought way cheaper from AliExpress and I think you can be under 20 euros in parts. The coding with all the libraries is to big for the Arduino Pro mini ATmega168, so keep that in mind and go directly for the Arduino Nano 328. If you chose this voltage regulator, make sure you adjust the output voltage before everything as it comes set to 12v or more. There is a small screw knob to do that. It takes many turns for the voltage to change.

Wiring           

The OLED and the two sensors communicate through the i2c of the arduino, which would be the SDA-A4pin on arduino and SCL the A5pin on arduino. The rest of the cables + and – will be connected to the 5v terminal and GND terminal on the arduino. The 5v power source will be connected: the + terminal to the VIN on the arduino and the – also to the GND.

Programming

            Download from my repository the 3 blocks of coding.

Update 28th of March 2019:

I included the libraries that you need directly in the directories where you have your code so you should not need to install libraries. This affects the next paragraph. You should be able to skip it.

Before starting with arduino, make sure you download and install the libraries stated at the beginning of the coding of TireTepmeratureSensor and they will be Adafruit_MLX90614.h, and U8glib.h. Look for these libraries with a google search and on how to install libraries to Arduino. It is easy. You can skip this paragraph (ass indicated above) if you download the files in my GitHub after 28th of March 2019.

But before connecting everything together you have to make some steps in order to have your components prepared to talk with the arduino at the same time. You will have to connect the components one at a time to your arduino and take the following steps:

1.-scan the device to see what address it has with the I2cScanner (one of the 3 programs you downloaded). After you upload the code to arduino, open the serial monitor from tools and you will be shown the address. For one of the sensor you don’t have to change the address so just write it down, and you will most likely get 0x5A.

For the second sensor you will get the same address after scanning and you will have to change it so that arduino knows which one is front and which one is for the back wheel and also not conflicting.

For the screen you only need to scan the device and write down the address in order to change it in the final code.

  1. – Change the address: In order to change the address for the second sensor, upload the ChangeAddress code and inside the code, put the address you want. It is set to change the address to 0x5B, but you can put your own if you want..if not, just upload the code to the arduino (with the sensor connected) and the address will be changed. Now upload once more the i2cScanner to make sure the address was changed. Do some unplugging of the board in between uploads to make sure it works fine. If you see that the address remains the same, just repeat this two steps.
  2. The final step is uploading the final code to your arduino.

Open the TireTemperatureSensor and if for the second sensors you let the address be 0x5B, while you didn’t touch the settings on the first one, then the front tire sensor will have the address 0x5A and the rear tire will have the sensor with the address 0x5B. Mark them with something so that you know where to place them on the bike. For the OLED you might also have the same address I had, but make sure and check that it is what you got when you scanned the OLED and if not, just change 0x3C with whatever you have (it appears 3 times in the coding).

For the sensors

Adafruit_MLX90614 mlx1 = Adafruit_MLX90614(0x5A);

Adafruit_MLX90614 mlx2 = Adafruit_MLX90614(0x5B);

For the OLED

uint8_t I2C_SLA = 0x3C;

and

I2C_SLA = 0x3C;

and

void loop(void)

{

I2C_SLA = 0x3C;

u8g.firstPage();

Wire everything together, place them in a case of your choice (I 3d printed the case and sensor supports) an mount them on the bike. For the rear tire I chose to place the sensor on the rear arm and for the front tire I chose to make a hole in the fender (towards the front as there will be less things being thrown from the tire). Also, the design is meant to avoid derbies getting on the sensor, so they are like some conical tubes. I chose to also put an ON/OFF button, cutting the power to the voltage regulator in case I need to reset the device or just have it OFF when I consider so (why would I do that…it is more for the first reason). On the screen you will see DANGER as long as the (front+back)/2 is less than 35. When it is >35 will show RACE. You can change the words and the value as well. For track days this value will have to be much higher and also according to what you consider appropriate for fast riding. Be careful that you can get the value over 35 if you come after a hard braking with the rear tire cold, so take a look at each temperature front and back as well before anything. You can also change «DRAAGOOD» to whatever you want…just take a look at the coding.

Update 09 of February 2019

Hello everybody! I am alive and kicking.

In the next days I will provide a link with the 3d design of the case I used and I will also bring you up to date with some improvements I made. As far as the electronics and the firmware: everything stays the same but I used some RJ11 connectors so it is easier to change a damaged sensor and also to install on the bike. The device can be powered through the USB port of the arduino in which case you should disconnect the dc-dc power supplier I coled voltage regulator. This means you can use a Power pack (used to charge phones) in order to power the device. You can also use as many sensors as you like but obviously there should be some alteration in the code I provided.

Have fun with it!

 

Here you can find the STL files so you can 3d print the parts you need to put the electronics in.

https://www.thingiverse.com/thing:3436054

As I said before, I used RJ11 connectors to make it easier to use: