TeensyNet Project Interest?

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Jim, any thoughts about running lighttpd instead of Apache? I've used lighttpd in the past, and it seemed fast and effective. PHP and MySQL appeared well supported, though I admit I never did anything terribly complex with any of it.

No reason why it shouldn't work, I've just never tried it. I used Apache/MySQL/PHP since it can be configured and run on Linux, Macs and Windows machines.

I've got a Pi, GertDuino, screw terminal shield, and a single DS18B20 sitting next to me running the 1-Wire library example code as I type this. I'm going to tinker with things on my own for a bit, but your project is highly likely to be incorporated if (when) I get tired of hacking around. I've also got a Teensy on the way ("pins" variant). I've not ventured into WIZ territory...yet...

My original system ran on an UNO. When I ran out of code and RAM space on it, I moved to a Mega2650, then to the Teensy3.0. Now with the Teensy 3.1, I can do a lot that I couldn't with any of the others, and still have plenty of space left for more improvements. :rockin:

My original board was capable of using the WIZ812mj, WIZ820io, or CC3000. The CC3000 proved to be VERY unreliable, and was dropped in short order. I settled on the WIZ820io since it's a much smaller footprint, and is supported in the latest code libraries.

Also with a PJRC WIZ820io & Micro SD Card Adaptor, my I2CEEPROM adapter board, and a few wiring changes, a TeensyPi board can be converted into a TeensyNet. :D
 
I've been out of the programming game since tiBASIC and haven't done any circuitry since highschool physics. But this is exactly what I want to implement once I get my temp control system set up. I'm getting the wife and I a pair of Arduino starter kits to learn the basics.

So a few questions:
1) Let me lay out my goals for my build. I'm pretty sure that teensy will do everything I need it to but don't have a full grasp on my requirements or teensey's capabilities. I plan to create a multi chamber box so that each chamber could be controlled independently. Each chamber would have temp probes. Temps below range would trigger a heater in the appropriate chamber. Temps above range would turn on a central fridge/freezer unit and use fans to move the air into the appropriate chamber. Ideally these ranges could be set remotely on a front end machine and the temp data could be logged there as well.
2) With these custom boards: are they completely bare bones? Will I need to solder anything together? Does it come with any necessary transistors/resistors/etc attached? I'm trying to change the level of skill I need to reach to complete a project of this complexity.

Thanks! I'm looking forward to this build once we move into our new space.
 
I'm suitably swayed to at least build a TeensyNet and give it a shot - WIZ820io and another Teensy 3.1 on the way.

I installed lighttpd, php-5, and mysql on the Pi - no issues thus far getting the basic functionality up and running.

What environment are you using for development? I despise the Arduino IDE despite my affinity for its simplistic code structures. I started configuring the arduino-cmake suite, but I haven't fully digested it. I'd rather just use avr-gcc and the like directly from the command line, but my low level Atmel hardware knowledge is pretty lacking, and I really have a hard time understanding the raw coded projects that I've seen around the web.
 
I've been out of the programming game since tiBASIC and haven't done any circuitry since highschool physics. But this is exactly what I want to implement once I get my temp control system set up. I'm getting the wife and I a pair of Arduino starter kits to learn the basics.

So a few questions:
1) Let me lay out my goals for my build. I'm pretty sure that teensy will do everything I need it to but don't have a full grasp on my requirements or teensey's capabilities. I plan to create a multi chamber box so that each chamber could be controlled independently. Each chamber would have temp probes. Temps below range would trigger a heater in the appropriate chamber. Temps above range would turn on a central fridge/freezer unit and use fans to move the air into the appropriate chamber. Ideally these ranges could be set remotely on a front end machine and the temp data could be logged there as well.

That would require a separate php module to monitor multiple Temp sensors, which would control a single fridge/freezer. While it's certainly doable, I haven't done it.

An Action Combo Switchboard per chamber could be used for heating / fan control.

2) With these custom boards: are they completely bare bones? Will I need to solder anything together? Does it come with any necessary transistors/resistors/etc attached? I'm trying to change the level of skill I need to reach to complete a project of this complexity.

Thanks! I'm looking forward to this build once we move into our new space.

There's a reason that This is in the DIY section :cross:

I've made the board designs and software Open Source so that anyone may use and modify the boards / software as they see fit. Since I use the hobbyist version of Eagle and am not a Vendor on this site, I would violate the TOS of this site and Eagle if I offered populated boards or kits.

I try to provide links for hard to find items, and most of the other parts are available from Jameco, Mouser, or Digikey.

Hope this helps
 
I'm suitably swayed to at least build a TeensyNet and give it a shot - WIZ820io and another Teensy 3.1 on the way.

What environment are you using for development? I despise the Arduino IDE despite my affinity for its simplistic code structures. I started configuring the arduino-cmake suite, but I haven't fully digested it. I'd rather just use gcc-avr and the like directly from the command line, but my low level Atmel hardware knowledge is pretty lacking, and I really have a hard time understanding the raw coded projects that I've seen around the web.

The Teensy3.1 requires the Teensyduino add-on to the Arduino IDE in order to compile and upload code to the Teensy3.1. The Teensy3.1 uses ARM rather than Amtel hardware.

If you search the PJRC Forums, you see several other options that are available (Eclipse, CLI, etc).

While I'm not crazy about the Arduino IDE, it's what I use since it's easy to set up and works for me on my Debian workstation (My wife has the only Windows computer in the house, and she refuses to give it up ;) ) It's also easiest for a noob to setup and use.
 
I don't want to take the thread too far off the rails, so I'll keep this one short. With a few hours' work, I've got a pretty usable, somewhat customized Arduino IDE on my Zorin distro laptop, including command line builds + Teensyduino. Full writeup here: http://yuri-rage.github.io/geekery/2014/02/27/arduino-ide---kustomized/

Back on track - the more I read about Teensy, the better I like it, and the more I recognize its potential in this project. What a neat little platform. I can't wait to actually try it out!
 
I'm posting the various boards that I've designed to work with the TeensyNet project at my website, along with links that allow you to order them from OSHPark.

OSHPark has a minimum order of three boards, so interested parties may want to get together and organize a group buy.

If anyone is interested in ordering a larger quantity of boards as a group buy, I can provide a set of Gerber Files that can be used to order from SEEEDStudio as well.
 
Jim, you include quite a few third party libraries in the TeensyNet sketch. I managed to get TeensyPi to compile by making some assumptions about the libraries.

Will you post reference links for those? Even better, it'd be prudent to include the versions you're using on GitHub as part of the project.

Also, the Arduino IDE that I love so much keeps opening EVERY sketch in the folder when one is opened (each as a new tab), and then tries to compile them into one combined binary, as if they somehow depend on one another. It's quite irritating. Do you keep the Teensy projects organized in exactly the same manner as they are on GitHub? If so, how do you keep the damn IDE from misbehaving?
 
Jim, you include quite a few third party libraries in the TeensyNet sketch. I managed to get TeensyPi to compile by making some assumptions about the libraries.

Will you post reference links for those? Even better, it'd be prudent to include the versions you're using on GitHub as part of the project.

Also, the Arduino IDE that I love so much keeps opening EVERY sketch in the folder when one is opened (each as a new tab), and then tries to compile them into one combined binary, as if they somehow depend on one another. It's quite irritating. Do you keep the Teensy projects organized in exactly the same manner as they are on GitHub? If so, how do you keep the damn IDE from misbehaving?

That was next on my list. Paul at PJRC recently released Teensyduino-18, and I've been verifying that everything works. I've had to modify a few of the libraries to take advantage of the greater amount of RAM and Flash.

I've just uploaded my working arduino and sketchbook libraries as zip files to my github account.

The only .ino file you need for the Teensynet is TeensyNet.ino . The TeensyOneWireSlave.ino is a separate program that emulates a 1-wire slave device.

Each .ino file should be in a separate directory in your sketchbook, name the directory with the same name as your filename, so for instance in my case it's:

(dir)home\
(dir)------sketchbook\
(dir)------------------libraries\
(dir)------------------TeensyOneWireSlave\
(file)---------------------------------------TeensyOneWireSlave.ino
(dir)------------------TeensyNet\
(file)-----------------------------TeensyNet.ino

The various .php, .css, html, and .js go into the directory used by your apache (lighttp) to serve webpages.

Sorry for the confusion, I'm working on a write-up on how to setup the development and web environments, but I probably won't get it done this weekend.:(
 
While I've developed several boards that allow the use of K-type thermocouples in the TeensyNet, they are either re-purposing a chip, which requires a fair amount of processing, or taking a chip that uses another protocol, such as I2C.

Maxim Integrated has now changed all of that with the introduction of the MAX31850 Cold-Junction Compensated, 1-Wire Thermocouple-to-Digital Converter. Now you can read K-type thermocouples directly on a 1-wire mini-lan.

One problem is that the chip is only available in a very small SMD package that would make it problematic to use in a home-designed board.

Adafruit has introduced a breakout board that solves that problem.

Adafruit chose to not provide a level-shifting interface, which would allow the board to be directly connected to a 5VDC mini-lan such as the one the TeensyNet uses. This was to allow the breakout board to be used in "parasitic mode" on low-voltage, low-power mini-lans. In order to use this breakout board with the TeensyNet, a level-shifting board is in the works, along with an Action Board that will include 2 DS2406 switches.

I have already integrated a breadboarded version of the level-shifter / breakout board into the TeensyNet software, and its working fine.

More to come.
 
Like Yuri, I'm impressed with the design and implementation of this suite of boards. Nice work.

I'm in the design stages of a major overhaul to my fermentation and storage room. I currently use numerous (6 to be exact) STC-1000's to manage the AC unit for room temp control, and 4 independent fermentation heaters (60 watt heating pads).

I'm looking at the TeensyNet board, several action boards, and an LCD board to run the whole thing.

My main question is this:

I note that the LCD board includes a 3-bit address select. Could this be wired to an 8 position rotary encoder and select AT RUN TIME different displays?

I'd like to have a single LCD mounted on the outside of my fermentation room, and be able to use the rotary selector to view various "pages" of data (maybe one page per fermenter, and one page for the AC controller data).​
 
Like Yuri, I'm impressed with the design and implementation of this suite of boards. Nice work.

I'm in the design stages of a major overhaul to my fermentation and storage room. I currently use numerous (6 to be exact) STC-1000's to manage the AC unit for room temp control, and 4 independent fermentation heaters (60 watt heating pads).

I'm looking at the TeensyNet board, several action boards, and an LCD board to run the whole thing.

My main question is this:

I note that the LCD board includes a 3-bit address select. Could this be wired to an 8 position rotary encoder and select AT RUN TIME different displays?

I'd like to have a single LCD mounted on the outside of my fermentation room, and be able to use the rotary selector to view various "pages" of data (maybe one page per fermenter, and one page for the AC controller data).​

This is why I like this forum, you always get new ideas and feedback :tank:

Using a BCD 8-position switch for setting the LCD board's address had occurred to me, but at a cost of nearly $7, I quickly opted for jumpers, since I had envisioned a real-time display board using multiple LCDs. Here's my latest setup:

MultiLCDs.png


I don't see any reason why a BCD switch could not be used on the fly, I just haven't tried it...yet ;)
 
This is an awesome thread, so cheers to all of your hard work. I've recently been getting up to speed on the arduino and similar controllers. My background is in mech engineering, but I'm relatively competent in EE. I currently just use STC-1000s to control my fridges, etc. My big concern is that is seems like every other week, a new product/design/update comes out that seems to make the last generation obsolete, am I making a mountain out of a molehill here?

I'm like many on here that just need a firm push in the right direction I guess to get rolling. Have you integrated the spark wifi controller? Do you think that'd be a more streamlined solution? It seems like for about $100, its feasible to have a dual zone wifi enabled temp control/monitor solution?
 
This is an awesome thread, so cheers to all of your hard work. I've recently been getting up to speed on the arduino and similar controllers. My background is in mech engineering, but I'm relatively competent in EE. I currently just use STC-1000s to control my fridges, etc. My big concern is that is seems like every other week, a new product/design/update comes out that seems to make the last generation obsolete, am I making a mountain out of a molehill here?

I'm like many on here that just need a firm push in the right direction I guess to get rolling. Have you integrated the spark wifi controller? Do you think that'd be a more streamlined solution? It seems like for about $100, its feasible to have a dual zone wifi enabled temp control/monitor solution?

I have a couple of the Spark boards from the Kickstarter rollout, I just haven't done anything with them yet.

As I recall, they use the TI CC3000 WiFi chip. I tried using the Adafruit CC3000 breakout board, and had lots of problems with it, including limited range, mysterious crashes, and no support for true TCP or UDP servers. I wrote my own UDP server library for it that was semi-successful, and finally gave up in frustration.

For WiFi, I'm currently using a modified TP-Link TL-WR703N that is rock-solid, albeit a little more kludgy.

I may revisit the TI CC3000 at a later date, but right now I have a system that just works.
 
Great progress, Jim! Your pace is easily outrunning my ability to source parts (which is a good thing, really). I hope to have a WIZ820io here this week so I can really dig into the project.

I've been enjoying some 1-Wire and serial comm tinkering with Teensy and RPi. TeensyNet nicely overcomes many of the serial communication woes I've experienced so far.
 
Jim,

Finally! A bit more hardware arrived. I have the WIZ820io connected properly to a Teensy 3.1, verified with the Arduino library examples.

Here's what I've run into so far while configuring TeensyNet:

Compiling TeensyNet.ino was very painful. There are no function prototypes defined, which threw a ton of compile errors (Arduino 1.05 + Teensyduino). I solved it by a lot of cut/paste, moving every function up to a point prior to its reference by follow on functions. I remember dealing with that issue once before in Arduino development, and I can't remember the solution to force proper preprocessing of sketch files.

I did not want to re-image my Pi (no extra SD cards laying around at the moment), so I created a TeensyNet directory on the web server and copied all applicable files from the git repository. However, I do not have a copy of the teensynet MySQL database. Can you include that in the repository (or provide the schema)? For now, I have created an empty database named teensynet, with all privileges allowed for the username, teensynet, password, teensynet.

I also discovered the requirement to create a /var/logs/teensynet directory with read/write privileges for the web server user. That was easy.

Since I don't have an EEPROM chip to use (my own dumb fault for not ordering one), I commented out most of the EEPROM reads/writes. That keeps the Teensy from hanging up as it waits for reads/writes that are impossible. I can now get the findTeensyNets.php script to register a device!

I do have the WIZ820io & Micro SD Card Adaptor from PJRC - I may explore that as an alternative to an EEPROM chip. I doubt that'll be hard to implement.

At this point, findChips() discovers the two DS18B20s connected to pin 2, and I've proven via serial output that the temperatures are correctly updated, but that's as far as I've gotten. I think the blank database results in a lot of web page misbehavior, though, so I can't see the temps via the web server.

Please comment your code a bit more thoroughly - I'm having a hard time reverse engineering your thought process at times. It'd also be nice to split the TeensyNet.ino sketch into smaller chunks, using .h and .cpp files to keep things organized.
 
Compiling TeensyNet.ino was very painful. There are no function prototypes defined, which threw a ton of compile errors (Arduino 1.05 + Teensyduino). I solved it by a lot of cut/paste, moving every function up to a point prior to its reference by follow on functions. I remember dealing with that issue once before in Arduino development, and I can't remember the solution to force proper preprocessing of sketch files.

Are you using the "pretty usable, somewhat customized Arduino IDE" you mentioned? If so, I think that that might be part of the problem. I've re-created the development environment, which is a pretty vanilla setup multiple times, and have not had the issues your mentioning.

I'm trying to keep the compile/upload side of things as simple as possible for noobs.

I did not want to re-image my Pi (no extra SD cards laying around at the moment), so I created a TeensyNet directory on the web server and copied all applicable files from the git repository. However, I do not have a copy of the teensynet MySQL database. Can you include that in the repository (or provide the schema)? For now, I have created an empty database named teensynet, with all privileges allowed for the username, teensynet, password, teensynet.

I also discovered the requirement to create a /var/logs/teensynet directory with read/write privileges for the web server user. That was easy.

I'm planning to do a write-up on how to set-up the web front end the hard way, but you got ahead of me on that one. I'll send a dump of the SQL via PM.

Since I don't have an EEPROM chip to use (my own dumb fault for not ordering one), I commented out most of the EEPROM reads/writes. That keeps the Teensy from hanging up as it waits for reads/writes that are impossible. I can now get the findTeensyNets.php script to register a device!

I originally used the on-board EEPROM in the Teensy3.0, but that limited the number of devices / actions / PIDs that I could handle. I wanted to take advantage of the huge space increase available in the Teensy3.1, so I added the EEPROM Chip.

I do have the WIZ820io & Micro SD Card Adaptor from PJRC - I may explore that as an alternative to an EEPROM chip. I doubt that'll be hard to implement.

That part wasn't available when I made the decision to use an EEPROM chip.

Please comment your code a bit more thoroughly - I'm having a hard time reverse engineering your thought process at times. It'd also be nice to split the TeensyNet.ino sketch into smaller chunks, using .h and .cpp files to keep things organized.

Yeah, I'll be the first to admit that the code isn't pretty ;) The main reason I'm keeping the code as a single (huge) file it to make it easier for neophytes to compile and upload the code for the Teensy3.x
 
Ok, this is interesting - I get zero compile errors if I select Teensy3.0 as the board type. I get a ridiculous amount of function "not declared in this scope" errors if I select Teensy 3.1. I reinstalled Teensyduino (1.18), and it did not help. I'll keep trying to track down the issue. My IDE is slightly customized, but it is not significantly altered (in fact, it is closer to "stock" than the ugly *buntu repository version).

Here's a snippet of the errors:
Code:
TeensyNet:781: error: 'findChips' was not declared in this scope
TeensyNet:782: error: 'saveStructures' was not declared in this scope
TeensyNet:800: error: 'readStructures' was not declared in this scope
TeensyNet:858: error: 'softReset' was not declared in this scope
TeensyNet:889: error: 'lcdCenterStr' was not declared in this scope
TeensyNet:918: error: 'pidSetup' was not declared in this scope
TeensyNet.ino: In function 'void loop()':
TeensyNet:957: error: 'udpProcess' was not declared in this scope
TeensyNet:983: error: 'updateChipStatus' was not declared in this scope
TeensyNet:988: error: 'updateActions' was not declared in this scope
TeensyNet:992: error: 'updatePIDs' was not declared in this scope
TeensyNet.ino: In function 'void readStructures()':
TeensyNet:1115: error: 'displayStructure' was not declared in this scope
TeensyNet.ino: In function 'void saveStructures()':
TeensyNet:1177: error: 'displayStructure' was not declared in this scope
TeensyNet.ino: In function 'void updatePIDs(uint8_t)':
TeensyNet:1345: error: 'actionSwitchSet' was not declared in this scope
TeensyNet:1351: error: 'actionSwitchSet' was not declared in this scope
TeensyNet.ino: In function 'void udpProcess()':
TeensyNet:1560: error: 'showChipInfo' was not declared in this scope
TeensyNet:1581: error: 'showChipAddress' was not declared in this scope
TeensyNet:1594: error: 'updateChipStatus' was not declared in this scope
TeensyNet:1649: error: 'setSwitch' was not declared in this scope
TeensyNet:1650: error: 'updateChipStatus' was not declared in this scope
TeensyNet:1769: error: 'lcdCenterStr' was not declared in this scope
TeensyNet:1800: error: 'showChipAddress' was not declared in this scope
TeensyNet:1816: error: 'showChipAddress' was not declared in this scope
TeensyNet:1840: error: 'showChipAddress' was not declared in this scope
TeensyNet:2072: error: 'matchChipAddress' was not declared in this scope
TeensyNet:2158: error: 'getAllActionStatus' was not declared in this scope
TeensyNet:2195: error: 'actionSwitchSet' was not declared in this scope
TeensyNet:2206: error: 'actionSwitchSet' was not declared in this scope
TeensyNet:2250: error: 'setSwitch' was not declared in this scope
TeensyNet:2309: error: 'MasterStop' was not declared in this scope
TeensyNet:2351: error: 'actionSwitchSet' was not declared in this scope
TeensyNet:2375: error: 'getPIDStatus' was not declared in this scope
TeensyNet:2439: error: 'asciiArrayToHexArray' was not declared in this scope
TeensyNet:2445: error: 'matchChipAddress' was not declared in this scope
TeensyNet:2481: error: 'matchChipAddress' was not declared in this scope
TeensyNet:2590: error: 'getPIDStatus' was not declared in this scope
TeensyNet:2607: error: 'actionSwitchSet' was not declared in this scope
TeensyNet:2643: error: 'showChipType' was not declared in this scope
TeensyNet:2661: error: 'asciiArrayToHexArray' was not declared in this scope
TeensyNet:2662: error: 'matchChipAddress' was not declared in this scope
TeensyNet:2686: error: 'actionStatus' was not declared in this scope
TeensyNet:2703: error: 'actionSwitchSet' was not declared in this scope
TeensyNet:2810: error: 'MasterStop' was not declared in this scope
TeensyNet:2817: error: 'EEPROMclear' was not declared in this scope
TeensyNet:2875: error: 'softReset' was not declared in this scope
TeensyNet:2881: error: 'EEPROMclear' was not declared in this scope
TeensyNet.ino: In function 'void getPIDStatus(uint8_t)':
TeensyNet:3011: error: 'showChipAddress' was not declared in this scope
TeensyNet:3028: error: 'showChipAddress' was not declared in this scope
TeensyNet.ino: In function 'void actionSwitchSet(uint8_t*, uint8_t)':
TeensyNet:3109: error: 'setSwitch' was not declared in this scope
TeensyNet.ino: In function 'void showChipType(int)':
TeensyNet:3150: error: 'addChipStatus' was not declared in this scope
TeensyNet.ino: In function 'void showChipInfo(int)':
TeensyNet:3157: error: 'addChipStatus' was not declared in this scope
TeensyNet.ino: In function 'void setSwitch(uint8_t, uint8_t)':
TeensyNet:3208: error: 'updateChipStatus' was not declared in this scope
TeensyNet.ino: In function 'void updateChipStatus(int)':
TeensyNet:3230: error: 'Read_TC_Volts' was not declared in this scope
TeensyNet:3231: error: 'Read_CJ_Temp' was not declared in this scope
TeensyNet:3258: error: 'TC_Lookup' was not declared in this scope
TeensyNet.ino: In function 'void EEPROMclear()':
TeensyNet:3621: error: 'lcdCenterStr' was not declared in this scope
TeensyNet:3638: error: 'lcdCenterStr' was not declared in this scope

UPDATE:
I added a single function prototype for findChips() right after the #INCLUDE statements, and it compiled without a hitch for Teensy3.1. I have no idea why that worked.

FURTHER UPDATE - IT WORKS!:
I've kludged together a working (crippled/breadboarded) TeensyNet! Due to my own shortsightedness, I have no EEPROM chip, and no LCDs to connect. However, the board is discovered through a TP-Link WR702n in client mode, and the DS18B20s display temperature on the sensor page. The conversion/refresh rate absolutely SLAYS the Arduino 1-Wire projects I've seen. I'm very encouraged!

For now, I enabled onboard EEPROM reads/writes for chip functions (at address 0xFF) and then disabled the action and PID structure reads/writes to avoid memory overflow. I might have learned about overflow errors the hard way after destroying a WIZ820io :D. Here are the code snippets I used to get things working:

Code:
//#include "I2CEEPROMAnything.h" // removed in favor of onboard EEPROM - yuri
#include <EEPROMAnything.h>      // added to enable onboard EEPROM - yuri

// function prototype to fix Teensy3.1 compile errors - yuri
void findChips();
Code:
// all I2CEEPROM_ functions are edited to look like this one:

EEPROM_writeAnything(EEPROMbjAddr, bonjourNameBuf); //, I2C0x50); // yuri - use onboard EEPROM
Code:
uint8_t const numLCDs  = 0; // 8; // I have no LCDs - yuri
Code:
// all lcd[7]-> statements look like this one:

// yuri - no lcd // lcd[7]->clear();

All of my edits are easily undone using find/replace. It'd be more elegant to use #IFDEF code, and even better to use those conditionals to implement micro SD card storage in place of the EEPROM. If I do implement #IFDEF conditional functionality, I'll likely use git to push an update to you.
 
The TP-WR702n that I got from Amazon showed up with the English firmware already loaded. It was a bit finicky at the start - I could not get client mode to connect. When I updated to the latest beta firmware (131211_beta), it worked flawlessly after using the quick start wizard to select client mode with all default settings, despite my urge to change them. I tried disabling SmartIP and enabling the DHCP server, but it seems that is more problematic than just leaving SmartIP enabled, at least in client mode.

I first tested client mode using my laptop's eth0 port - it connected and was able to ping, ssh, and web browse, both on the Internet and the .local domain.

I then connected the TeensyNet board to the TP-WR702n - it immediately assigned an IP address and made it discoverable with no further configuration. I explored no further. It just plain worked.

I got one of the WIZ820io adapter boards soldered up today. The example SD sketches work as advertised, and the ethernet port is working. Next up: configuring TeensyNet to use SD storage as an alternative to EEPROM.

I dig the thermocouple board. I saw the code - nice work with the "overloaded" switch/case statements.
 
The TP-WR702n that I got from Amazon showed up with the English firmware already loaded. It was a bit finicky at the start - I could not get client mode to connect. When I updated to the latest beta firmware (131211_beta), it worked flawlessly after using the quick start wizard to select client mode with all default settings, despite my urge to change them. I tried disabling SmartIP and enabling the DHCP server, but it seems that is more problematic than just leaving SmartIP enabled, at least in client mode.

I first tested client mode using my laptop's eth0 port - it connected and was able to ping, ssh, and web browse, both on the Internet and the .local domain.

I then connected the TeensyNet board to the TP-WR702n - it immediately assigned an IP address and made it discoverable with no further configuration. I explored no further. It just plain worked.

Ya talked me into it, just ordered two to try. :mug:
 
I didn't have time to flesh out the SD I/O in the actual TeensyNet.ino sketch today, but it's likely to be very straightforward. The proof of concept sketch below successfully writes a chipStruct array to a file on the SD card, then reads it into another variable and displays it. No modifications to the Arduino SD library required. That was easy!

Code:
// SD structure read/write test
// Modified Arduino SD Library example sketch: ReadWrite
// Borrows structure definitions/functions from TeensyNet.ino v0.0.29
// Yuri - 03/21/14

#include <SD.h>

File myFile;

const int     chipSelect     = 4;  // Teensy3 w/WIZ820io+SD adapter: pin 4
const uint8_t chipAddrSize   = 8;  // 64bit OneWire Address
const uint8_t chipNameSize   = 16;
const uint8_t maxChips       = 36; // Maximum number of Chips

typedef struct
{
  uint8_t    chipAddr[chipAddrSize];
  int16_t    chipStatus;
  uint32_t   tempTimer;
  char       chipName[chipNameSize+1];
}chipStruct;

chipStruct chip[maxChips] = 
{
  { {0,0,0,0,0,0,0,0}, 0, 0, "Stuff\0          " },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {1,0,1,0,1,0,1,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" },
  { {0,0,0,0,0,0,0,0}, 0, 0, "" }
};

chipStruct sdOutput[maxChips];

void displayStructure(byte *addr, int xSize, int ySize)
{
  int x, y;
  Serial.print(F("0x"));
  Serial.print((uint32_t)addr, HEX);
  Serial.print(F(": ")); 
  for(x = 0, y = 0; x < xSize; x++)
  {
    if(addr[x] >=0 && addr[x] <= 15)
    {
      Serial.print(F("0x0"));
    }else{
      Serial.print(F("0x"));
    }
    Serial.print(addr[x], HEX);
    y++;
    if(y < ySize)
    {
      Serial.print(F(", "));
    }else{
      y = 0;
      Serial.println();
      Serial.print(F("0x"));
      Serial.print((uint32_t)addr + x + 1, HEX);
      Serial.print(F(": ")); 
    }
  }
  Serial.println();
  Serial.println();
}

void setup()
{
  Serial.begin(115200);
  
  delay(5000); // wait 5 seconds to allow for opening serial monitor

  Serial.print("Initializing SD card...");
   
  if (!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  
  if (SD.exists("test.txt")) {
    Serial.println("test.txt exists.");
    // delete the file:
    Serial.println("Removing test.txt...");
    SD.remove("test.txt");
  }
  else {
    Serial.println("test.txt doesn't exist.");  
  }
  
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);
  
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    //myFile.println("testing 1, 2, 3.");
    myFile.write((byte *) &chip, sizeof(chip)); // byte-wise write of structure
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
  
  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("Structure from test.txt:");
    
    myFile.read((byte *) &sdOutput, sizeof(sdOutput)); // byte-wise read of structure
    
    // serial output of structure from file
    displayStructure((byte *)(uint32_t) &sdOutput, sizeof(sdOutput), sizeof(chipStruct));
    Serial.print( (sizeof(chipStruct) / sizeof(byte) ) * maxChips);
    Serial.println(F(" bytes in chip structure array"));

    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop()
{
  // nothing happens after setup
}
 
I spent some time thinking about the easiest way to implement an SD card alternative. I think I figured it out, though it is perhaps inelegant. I haven't written the SD file I/O yet, but the I2CEEPROM functionality appears unchanged if selected.

First, I created two additional header files - TeensyNetI2CEEPROM.h, and TeensyNetSD.h.
Code:
// #include "TeensyNetI2CEEPROM.h" // added   - yuri - comment/uncomment as required for I2CEEPROM
// #include "I2CEEPROMAnything.h"  // removed - yuri - included in TeensyNetI2CEEPROM.h
#include "TeensyNetSD.h"           // added   - yuri - comment/uncomment as required for SD storage (mutually exclusive with I2CEEPROM)

The additional headers provide "wrappers" for the I2CEEPROMAnything read/write classes, along with a renamed EEPROMclear() function, which is implemented in a .cpp file:
Code:
/* TeensyNetI2CEEPROM.h

   yuri - Mar 2014
*/
#include <Wire.h>
#include <I2CEEPROMAnything.h>

// constants
const uint32_t   I2CEEPROMsize         = 0xFFFF;  // MicroChip 24LC512
const uint8_t    I2C0x50               = 0x50;    // device address at 0x50
const uint8_t    pageSize              = 128;     // MicroChip 24LC512 buffer page
const uint8_t    chipNameSize          = 16;      // character array size for chip names

// prototypes
void storageClear(void);

// wrappers for I2CEEPROM_Anything classes
// allows for providing functions of the same name in an SD card library for alternate storage options

template <class T> uint16_t teensynet_readAnything(uint16_t ee, T& value, uint8_t device)
{
  return I2CEEPROM_readAnything(ee, value, device);
}

template <class T> uint16_t teensynet_writeAnything(uint16_t ee, const T& value, uint8_t device)
{
  return I2CEEPROM_writeAnything(ee, value, device);
}

I'll likely use the EEPROM addresses to implement a file numbering scheme, and create a file on the SD card for each stored structure.

Best I can tell, those changes do the least damage to your existing work while providing some pretty solid flexibility. Please let me know if you dislike the direction I've taken - I'm all ears to criticism.

As an alternative, it'd be slick to test for presence of an SD card and/or EEPROM, and offer a choice of storage options via the web server upon first discovery. That would avoid reprogramming or versioning of TeensyNet boards.

The SD card certainly offers the capability for offline data logging, so I'd like to continue incorporating it, even if EEPROM is the way to go for non-volatile storage of small data structures.
 
I'd thought about using an on-board SD card before Paul came out with the WIZ820io & Micro SD Card Adaptor, but I figured that the datalogging on the Teensy3.x wouldn't be much use without a RTC. The Teensy3.x has the ability to add a crystal and battery and implement a RTC, which could now be set via ntpd, and do some useful offline datalogging.

I'd probably still use the I2CEEPROM to store the TeensyNet data structures, since I'd be less likely to inadvertently remove the I2CEEPROM during a Senior Moment. :cross:

Where I think the SD card may be useful would be in the storage and execution of more complex actions, such as long term lagering, and double and triple mash profiles. You could create the profile off line, save it on the SD card, then insert the SD card into the TeensyNet and execute it in real time. The Teensy3.1 board has enough Flash and RAM to do that.

I made the TeensyNet Open Source specifically so that polymaths like you can add your own ideas. Feel free to fork off and do your own thing, just make it available to us all. :mug:
 
Progress like crazy!

I've decided on a different direction in my effort to add flexibility. It shouldn't be difficult to search for presence of an EEPROM and/or an SD card, then use whichever is present, with a preference for EEPROM if both exist neither has saved data. I don't want to stray too far from your project - I'd rather contribute than diverge. I've got some 24LC512s on order, along with a few other odds and ends.

I'd like to explore PWM output as an option to control electric heating elements or motor speed via variable duty cycle. Ideally, it'd be implemented via a 1-Wire device, but I'm not aware of one, save for the strange and very expensive BAE0910.


A couple of questions on unused objects in the sketch:

Why define 8 Adafruit_RGBLCDShield objects when you only update one of them in the main loop?

Also, why define a 24LC512 at address 0x51? Were you planning on adding more storage? What would be stored?


And one last, rather nitpicky question for now:

The default device name uses "TeensyNet" followed by the last octet in the IP address. Wouldn't the name be more likely to be unique if it was numbered by some portion or hash of the MAC address? Or is that fairly moot since it appears the intent is to name each board via the web interface?
 
Progress like crazy!

I've decided on a different direction in my effort to add flexibility. It shouldn't be difficult to search for presence of an EEPROM and/or an SD card, then use whichever is present, with a preference for EEPROM if both exist neither has saved data. I don't want to stray too far from your project - I'd rather contribute than diverge. I've got some 24LC512s on order, along with a few other odds and ends.

Works for me.

I'd like to explore PWM output as an option to control electric heating elements or motor speed via variable duty cycle. Ideally, it'd be implemented via a 1-Wire device, but I'm not aware of one, save for the strange and very expensive BAE0910.

You might be able to do that to some degree by rapidly switching the DS2406 on/off. In that case you'd be limited to the time it would take to access the part via 1-wire.

Another option would be to use a Teensy3.x as a 1-wire slave using my TeensyOneWireSlave.ino as a starting point.

A couple of questions on unused objects in the sketch:
Why define 8 Adafruit_RGBLCDShield objects when you only update one of them in the main loop?

You can assign an LCD to an action, and the action update portion of the code will display the status of that action on the LCD you've selected. There's also code that allows the Web Interface to modify any of the LCDs.

If you look here, you'll see a photo of me testing all eight LCDs.

As an aside, I'm doing a proof of concept now that would allow control of up to eighty-eight(! :eek: !) 4x20 LCDs.

Also, why define a 24LC512 at address 0x51? Were you planning on adding more storage? What would be stored?

I was adding the option in order to store other items like multi-step profiles, etc. You could access up to 8 24LC512 for 4MB of storage.


And one last, rather nitpicky question for now:

The default device name uses "TeensyNet" followed by the last octet in the IP address. Wouldn't the name be more likely to be unique if it was numbered by some portion or hash of the MAC address? Or is that fairly moot since it appears the intent is to name each board via the web interface?

I have a test program that allows me to directly access the TeensyNet via its low level commands using UDP. With it I can look at various information, and set debug levels on the fly which are output via the serial port. Since the TeensyNet uses DHCP to set its IP address, it's convenient to know the last octet so I can access the Teensynet directly.
 
Another option would be to use a Teensy3.x as a 1-wire slave using my TeensyOneWireSlave.ino as a starting point.
I saw that sketch and was intrigued by it. I may have to try that out! I don't think PWM output through a DS2406 will be very effective.
You can assign an LCD to an action, and the action update portion of the code will display the status of that action on the LCD you've selected. There's also code that allows the Web Interface to modify any of the LCDs.
Doh! My mistake.
 
Nice! Thoughts on integration? Touch interface?

I wasn't planning on using the ST7735 on a permanent basis, since it communicates via SPI, and the WIZ820io seems to lock up the SPI data line once the Bonjour service is started, which could also make SD card use problematic. I used software enabled pins to get the display to function properly, rather than the hardware SPI pins.
 
Nice! Thoughts on integration? Touch interface?

I wasn't planning on using the ST7735 on a permanent basis, since it communicates via SPI, and the WIZ820io seems to lock up the SPI data line once the Bonjour service is started, which could also make SD card use problematic. I used software enabled pins to get the display to function properly, rather than the hardware SPI pins.

Good to know, the driver board for this one uses SPI as well, I'll have to investigate.

I got two of the TL-WR702n devices today, so that's moved up on my list.
 
The TP-WR702n that I got from Amazon showed up with the English firmware already loaded. It was a bit finicky at the start - I could not get client mode to connect. When I updated to the latest beta firmware (131211_beta), it worked flawlessly after using the quick start wizard to select client mode with all default settings, despite my urge to change them. I tried disabling SmartIP and enabling the DHCP server, but it seems that is more problematic than just leaving SmartIP enabled, at least in client mode.

I first tested client mode using my laptop's eth0 port - it connected and was able to ping, ssh, and web browse, both on the Internet and the .local domain.

I then connected the TeensyNet board to the TP-WR702n - it immediately assigned an IP address and made it discoverable with no further configuration. I explored no further. It just plain worked.

Yup I can confirm that as well :rockin:

I'll add the TL-WR702n to my webpage
 
Last edited by a moderator:
I'm making a bunch of progress - I've got a kludged together TeensyNet using SD card storage and a TFT LCD. I don't think I'll push the code to you since it's really just a bunch of workarounds to use the hardware at hand (way too many nested conditionals), but you're welcome to see the mess I've made if you're interested.

The SPI data pin isn't "locked" during Ethernet routines as I previously mentioned. The issue, which manifested itself somewhat strangely/inconsistently, was really that Adafruit_RGBLCDShield routines tend to crash when you don't have an LCD connected. I recommend testing for an LCD at a given address before attempting to control it.

Next issue - many of your php scripts use "localhost" in hard coded absolute URLs. I'd rather use relative addressing, but that seems to break the scripts.

Also, a suggestion for future hardware design: Consider adding a header configuration with ~28 pins total (each connected to a Teensy pin) in order to make the boards either stackable (shields) or allow connectivity via 26 or 34 pin ribbon cables. Keep the screw terminals for easy bench testing and peripheral connections.

If you want to add SD/datalogging functionality, the existing TeensyNet board(s) easily support stacking a WIZ820io adapter from pjrc.com (leaving the TeensyNet board's WIZ820io footprint unpopulated).

teensynet-screenshot.jpg
 
The SPI data pin isn't "locked" during Ethernet routines as I previously mentioned. The issue, which manifested itself somewhat strangely/inconsistently, was really that Adafruit_RGBLCDShield routines tend to crash when you don't have an LCD connected. I recommend testing for an LCD at a given address before attempting to control it.

OK. I'll look into that.

Next issue - many of your php scripts use "localhost" in hard coded absolute URLs. I'd rather use relative addressing, but that seems to break the scripts.

What kind of errors do you get? Relative addressing in PHP can be quirky.

Also, a suggestion for future hardware design: Consider adding a header configuration with ~28 pins total (each connected to a Teensy pin) in order to make the boards either stackable (shields) or allow connectivity via 26 or 34 pin ribbon cables. Keep the screw terminals for easy bench testing and peripheral connections.

I'll keep that in mind.

If you want to add SD/datalogging functionality, the existing TeensyNet board(s) easily support stacking a WIZ820io adapter from pjrc.com (leaving the TeensyNet board's WIZ820io footprint unpopulated).

Yup. You can also make a few changes to a TeensyPi board, add the PJRC adapter, and convert the TeensyPi to a TeensyNet pretty readily.
 
Back
Top