Moped data acq attack

You like data? How do you like these data?

I saw Tyler dead possums is on to some shit that he posted in the trailtech repair thread, me and Lee are comparing notes. I am testing a product I've been working on for years and kinda stumbled on this rad mini Arduino with build in SD card support.


Got this Lil adafruit feather adalogger wired up last night, gonna try to use some cheap 100k NTC thermistors, so far the code is good using the SH equation up to about 200c. Seems to kinda fall apart after that.

Gonna write the code to store data on the SD card tonight and try to get everything cleaned up this weekend with some kind of better wiring or at least more hot glue and zip ties.

Re: Moped data acq attack

Also, I just threw junk in there too get the code working for now but I have a thermocouple amp chip that I plan on integrating also. 2 thermistors (cht, oil, water, etc) and 1 thermocouple for EGT. No idea what the point of all this is, I don't even use cht for tuning.

Cool thing even with all the sensors and ancillary shit this is like $80 into this project and once I prove it out I can get some cheaper stuff from China to make this like a $50 deal.

Re: Moped data acq attack

What resolution is the time scale?

This is going to be so bitchin if you get it all worked out dude.

Re: Moped data acq attack


Is that length or thickness?

Re: Moped data acq attack

Resolution is whatever I want within reason, I've got a pretty long delay in there right now because if you don't, the numbers can't draw fast enough and they get all blurry, but I'm going to add a Max temp function (real simple, just if new temp is greater, save new temp to Max temp each loop) and the write to the SD card will take a couple clicks, so practically speaking probably about 20 times a second without getting into fancy timers and stuff.

When I'm on the computer one of these nights, I'll put up all the links to the parts and a wiring diagram. I was just doing a little toilet-based research and found that you need to use a resistor similar to the resistance of the thermistor at the temp you want to read for the voltage divider, to keep it in the effective range of the response curve. I don't totally understand all the mumbojumbo but I saw 4.7k instead of 100k so I'll try that and see what happens.

Re: Moped data acq attack


I got an RTD setup I'm gonna try to get going this weekend...


Re: Moped data acq attack

🇮🇹💦 Of the Loin /

I would like to make/maintain a GitHub repo for stuff like this

Can I help with that

Re: Moped data acq attack

Yeah that would be great! I'm quite honestly embarrassed to share most of the uC shit I do because it's so sloppy. I usually get something working just good enough and say in gonna go clean up and comment code later and I never do. I have a pile of random micro projects I've built that I used for like one thing then bailed. That breadboard in the pic actually still has a rudimentary ignition circuit I was fuckin with.

I need to get other stuff done tonight, maybe Sunday night I can do some documentation. I'm gonna try to find time this weekend to get some sensors installed at least as proof of concept.

Re: Moped data acq attack

> daan SJAARLOOS wrote:

> -------------------------------------------------------

> Is that length or thickness?

Haha length in inches of course, I was drunk as hell last night at about midnight writing all this

Re: Moped data acq attack

🇮🇹💦 Of the Loin /

Eh, I'm happy to organize it, maybe even push a commit or two.

It's better that this kinda stuff is preserved so other folks can build off it

I have like a basic RTOS setup for Arduino I can share as well it sets up all the stuff you need for fun

Re: Moped data acq attack

Recently used an adafruit board at work, one of the little round ones for teaching kids to code...they put me in charge of teaching kids. Some of them got it.

Post git repo link and I my clean it up for you.

Re: Moped data acq attack

Made some good progress last night... Not really forwards but progress.

So I had 3 channels of A in coded and working using the manual SH equation from adafruit, I was actually using the example code from

But after about 150c it would basically stop rising. So i did a bunch of research and figured out that the way I had the voltage divider setup, basically the voltages were so close to 3.3 at those high temps, it basically couldn't read.

So I swapped the resistors around and went to change the "r1" in the code but it was actually set to 10k even though I was using a 100k thermistor. Ok that's weird.

So I changed it and it went totally haywire. After a bit more research I figured out that the circuit basics code is basically ripped off from adafruit and adafruit used a 10k thermistor, then basically the whole of the internet just ripped them off... Go figure. I read though a million comments and didn't see one person mention that it's all wrong. Around room temp the voltage divider is about the same as long as r1~=r2, but as soon as you go 40 deg or so from 70f, the equation doesn't hold true. Or maybe I'm just dumb? Lesson learned don't trust innernet dummies.

So I went back to the drawing board and found the NTC-thermistor library. If you search for a thermistor lib the big one that comes up is some stupid proprietary thing. A big more digging and this one looks good. It lets you put in beta ratio and all that.

Only problem is that it's coded by some big brain computer dude and he uses a very weird (probably more sophisticated) syntax than the kind of crap I write. It took me a bit but I was able to mangle my display code into shape to work with the new library.

So by about 1:30 I had one of the inputs working, the way variables are setup in the function I'm not quite sure how to create another instance for another input, but I was able to measure over 500f from my soldering iron (at God knows what accuracy) so I think this will be a more sustainable path forward.

Maity if u want to set up a GitHub repository that would be cool, I could def use a hand fighting my way through this code. Eventually I might even spin up a little shield that could hold the ballast resistors, a thermocouple amp and the VR conditioner that I'll need to make this show rpm. That's a long ways off.

Re: Moped data acq attack

Yo, I started a project like this years ago. You can read about it here, I never got to the next stage because I'm a dumber and couldn't figure out how to read rpms reliably to do calculations with it. We should chat. Now that we are reacquainted.

Arduino Speedo Project.

I had a github setup for my project, link in the link.

Re: Moped data acq attack

🇮🇹💦 Of the Loin /

Yeah maybe Sunday night or Monday at work I'll set one up

This is the base layer for an Arduino CDI someone else was coding up on the forums. It's just the RTOS setup functions I think


Re: Moped data acq attack

Haha yeah funny because I've been working on the CDI thing too, I was pretty close back in 2015 in Texas where I was working with uC engineers all day and they could answer all my dumb questions. I had actually gotten the timer interrupt working and the scr circuit triggering the coil but I realized that it wasn't going to work the way I was planning on doing it. I'm building a speeduino for my Subaru slash future Ford truck project, there are some real smart folks in that community and they have made some bare Bones units that could be a basis for an ignition only unit. There was also a guy on a Opel forum that built a really nice simple ignition controller that I was trying to contact. Maybe if we put together a real project he would be interested in helping.

This temp display logger was just something I need for a part that I'm designing but these M0 chips are so powerful now that it really wouldn't take much to do all the sensors you could want and still have plenty of CPU left to run a CDI, display, whatever. I don't know what the timer architecture is like on these compared to the traditional a32p stuff, but I'm sure someone has figured it out.

Re: Moped data acq attack

Yeah I've been meaning to get back to that. I've been more focused on the moped dashboard stuff. I have temp and audio working, and integrated a little text to speech engine so I can make my moped say stupid stuff.

Re: Moped data acq attack

And yeah, for temperature sensing I'm using a K type thermocouple with a MAX6675 driver chip. It's super simple and supposedly good up to 1000°C.

If you're rolling your own sensor using an RTD, there are a whole bunch of things to consider. A four-wire measurement system is recommended for any case where accurate readings are important (to eliminate lead wire effects). The dynamic range and resolution of your ADC vs the expected min and max resistance values of the sensor are also important. Also, RTDs are only approximately linear.

This article is pretty good: (edited)

Re: Moped data acq attack

See, that's why my project stalled, the cdi just wrecks my sensors, I need to learn tha whole twisted pairs, shielding, whatever tech. Cause it's chaos on my system.

Re: Moped data acq attack

You could try a shielded plug wire; using a robust single point ground will help a lot too.

Re: Moped data acq attack

tried, didn't work. I need to figure out the stuff.

Re: Moped data acq attack

Brian, how is the thermocouple working? I was planning on hooking it up for EGT with that max6675 but I haven't got this on a bike yet to see.

I was kinda avoiding the thermocouple for 2 reasons, cost and I wanted to make this plug and play with existing trailtech plug/cht sensor. I was kinda hoping someone would have a better library with at least some kind of lookup table but this should work good.

Re: Moped data acq attack

> Graham Motzing wrote:

> -------------------------------------------------------

> Brian, how is the thermocouple working? I was planning on hooking it up

> for EGT with that max6675 but I haven't got this on a bike yet to see.

It's great. Haven't tried it on a bike yet, but it was stupidly easy to set up. Type K CHT sensors exist and aren't that expensive, so I was just gonna pick up a few once this system was ready.

> I was kinda avoiding the thermocouple for 2 reasons, cost and I wanted

> to make this plug and play with existing trailtech plug/cht sensor. I

> was kinda hoping someone would have a better library with at least some

> kind of lookup table but this should work good.

You should be able to make your own table pretty easily by fitting the rtd equation to the readings you get for ice water and boiling water.

Re: Moped data acq attack

Yeah getting the table isn't hard I can get one online or if I buy good name brand thermistors I can get it from the mfg, I just don't want to figure out how to program it to use the table.

I'm using an NTC thermistor instead of an RTD because they are cheaper and the resistance changes more significantly so you don't need a separate amplifier chip. Ultimately you only get 1023 bits from the analog input and they are spaced evenly from 0-3.3v so the challenge is getting your dv/dtemp as large as possible in the effective range you want to measure. If you want to push the range all the way out to the max of 300c that means you will have fairly poor resolution at room temp, which is fne just kinda annoying when it's jumping 20 degrees just sitting there. There are a couple tricks I can use to smooth the data, and I've also heard to use a filter cap on the circuit although that's more components I would like to avoid.

Re: Moped data acq attack

Yeah, that's the sort of thing I was talking about with my comment about dynamic range and resolution. A 10 bit ADC is somewhat limiting.

A filter cap will cost you all of $0.10, but whether or not it's necessary is a function of the amount of noise in your circuit. If you're just driving a voltage divider with a DC voltage, it shouldn't be too bad.

If I were doing this and wanted to avoid the low temp jitter, I'd just ignore anything below like some temperature like 100C and display "low".

Re: Moped data acq attack

Yeah that's a good idea, the other thing I was just thinking about was maybe rather than putting in the delay, I'll actually have it write to a variable that does some kind of averaging function. Like have it write a little table with say 5-10 readings, then do a average of the table to refresh the display. Right now it just sits and does 500 counts of delay so the display has time to switch the pixels.

I bet if I'm running 3 channels and doing a 10 count average, with all that math, that will easily be as much time or more than the 500 cycle delay.

Like I said the long term plan is maybe spin a board with some of these circuits built in so the less components period, the better just for everything

Re: Moped data acq attack

Sure, that's dead simple in software.

Re: Moped data acq attack

I figured out an even easier way to do it, for(1-10) add sumtemp=temp +sumtemp, then divide that by 10

Then print that

Re: Moped data acq attack

🇮🇹💦 Of the Loin /

Run a task to manage the screen, then use a separate task to do the calcs

RTOS tasks mean you don't need to throw a bunch of delays in to your code and potentially block other functions from executing

I have to do work today so that means I'm in the GitHub mood. I'll clean up my RTOS code to be useful too

Re: Moped data acq attack

Busy weekend, wow, barely had time to touch this.

Here's some of the info for people that want to play along at home:

So the basis is this adafruit feather adalogger. Out of all the flavors of arduino, i picked this one because i liked the built in SD support and the form factor matches up to a good little screen. Also I already had a 3.7v lipo battery to run it, its got native USB and quite frankly i just thought the name was clever, haha. Also its an ARM m0 chip instead of the 32u4 so its faster and has more ram and all that fun stuff.

I mated it to this screen also from Adafruit. I took a guess at it, but it actually worked out perfect for displaying 3 lines of temp. The way the characters and formating and all that worked, it was better to do 3 horizontal lines, easier to read, but i would like to eventually code some kind of bar graph or something fancy.

As an added bonus, its got a 'stemma qt' port which is just a nice lil plug and play i2c interface, i could add networked sensors or all kinds of other weird stuff later.

These are the thermistors i'm using. They are 100k NTC thermistors known as '3950' because they have a beta coefficient of 3950. Lots of 3d printers use them, they can handle up to 300C (theoretically) and they have the largest change in resistance which is good for resolution.

oh what else, i also have a 3.7v 100ma lipo from adafruit. The feather has a built in charging circuit which is flippin' rad... eventually i can use my onboard usb charger to charge it, but i probably will get quite a few hours runtime out of this as it is.

Re: Moped data acq attack

Next, hooking it up:

This really is the gold standard for explaining how to hook up these lil' guys to an arduino. Pretty much every other site on the web is just a poorly written paraphrase version of this.

The circuit basics site was also helpful because they talk about 100,000 ohm thermistor specifically, but after a lot of head scractching, it turns out they just copied the Adafruit code and fucked it up. As i was saying earlier, they are using the coefficient and r1 for a 10k thermistor, and circuit basics (i'm not gonna do them the favor of linking) just copied it verbatim without converting it to a 100k ohm thermocouple.

I wrote my code to use pins a1, a2, a3 just because the feather is using a0 for some stuff and i didn't want any confusion.

I'm still sorting out the ballast resistors and playing around but right now i'm using 10k ohm. The analog input pin only knows if its seeing between 0-3.3 volts, it divides that into 1024 bits, and reports which bit out of 0-1023 its reading. The trick with the resistors is to spread out the change in voltage based on the change in resistance across as big of an area as possible. I could actually plot all this out in excel but i'm lazy and that feels way too much like college. blech.

Anyhow, nothing much more than that to say, super simple to hook up, i just have all the +3.3v outputs all hooked to the same pin, seems to be working so far. There will be a balancing act for the 500ma power supply, the resistances, and setting everything up so its not burning power for no reason, but so far it doesn't seem to be a problem and i haven't run it long enough to find out.

Want to post in this forum? We'd love to have you join the discussion, but first:

Login or Create Account