Maker Faire Louisville

Summary

On Saturday, as promised, I went to Maker Faire Louisville with my Lab Assistant Nicholas.  I gave out the Cypress CY8CKIT-049 development kit to everyone who asked.  This kit is really cool as it has a PSoC4200 and a Cypress USB Serial UART bridge.

It comes in this flat cardboard mailer.

CY8CKIT-049

CY8CKIT-049

I made a bunch of videos on how to use the kit.  You can find them on youtube or on Cypress.com.

The development kit is cool for a bunch of reason.  First, it is only $4.. which is awesome as I am not aware of anyone else out there was a bad ass kit like this for less.  Second, you can break off the programmer, then solder the development kit directly into your design.  So it is perfect to support your prototyping issues.  Third, you can plug is into your computer directly, without a cable, and boatload new firmware into the PSoC4200.  Finally, after you break off the programmer you are left with a USB to UART bridge to use for other things.

Maker Faire Louisville Pictures

Here are some of the “Where is waldo.? I mean where is the IoT Expert?” pictures that I took for twitter.

Maker Faire Louisville
At my office in Lexington with the twitter teaser picture for Maker Faire Louisville
Maker Faire Louisville
A few beers at Gordon Biersch before Maker Faire Louisville.

Maker Faire Louisville
At the entrance to Maker Faire Louisville

Maker Faire Louisville
At the GE First Build Forget demonstration at Maker Faire Louisville
Maker Faire Louisville
With Bill Cloyd of Newton’s Attic at Maker Faire Louisville

Maker Faire Louisville
With Adam Carlson A.K.A twitter aeroengineer1

This was my first meeting with Adam in person.  He works on giant giant giant engines that are use on the Boeing 777.  The Fan in the engine is like 11 feet tall.

But more interesting,  he is the editor for the EE Times website electroschematics.com

EE Times Electroschematics.com

While we were chatting he asked me to build an example project using PSoC with USB and a bulk endpoint.  I gave him a reference to a video made by Jon Moeller.  But, I thought that it would be a good idea to create a page of reader requests for this website… which I will do.

Here is the link to the Jon Moeller Video on PSoC5 and Bulk USB Endpoints.

https://www.youtube.com/watch?v=dQdCqX84jXQ

 

Cypress Development Kits & the GE Mega Hackthon

Summary

I spent this weekend attending the GE Mega Hackathon at GE FirstBuild.  First Build is a Maker Space-ish place in Louisville that is sponsored by GE and Louisville Speed School.  The Hackathon was called “Hack the Home” and was a two day thing where teams of makers built stuff for the house… generally by modifying GE white goods. Nicholas, my lab assistant, and I brought a bunch of Cypress Development Kits for people to use… then we helped them modify the kits to put them in their hacking projects.

Nicholas with the pile of Cypress Development Kits Cypress Development Kits

At the table next to us were two guys from OnShape which is a cloud based 3-d drawing application.  It is super cool and free to use for non-comercial applications.  Nicholas is totally into 3-D printing and has been using Tinker CAD, which is cool… and free… but is still mostly a toy.  OnShape on the other hand is a fully featured pro package.  Philip, one of their applications engineers, helped Nicholas get going.

Nicholas & OnShape

I brought a bunch of different Cypress Development Kits, but what got people really interested was CapSense.  I had three different Capsense kits which fired peoples imagination…. first, the CY8CKIT-145 (which I have written extensively about) has three buttons and a slider… plus LEDs and a Bluetooth module on the back.

CY8CKIT-145
The CY8CKIT-024 Proximity shield which works with most any of the Pioneer kits.

CY8CKIT-024

And finally the CY3280 MBR3 development kit.  This has 4 capsene buttons, a buzzer and a proximity loop… in an Arduino shield format factor.  To talk to the shield you use I2C.

CY3280 Cypress Development Kits

What is really cool is that you don’t have to write firmware as you just configure it with EZ-Click.

EZ Click

Several people used it, including this guy who was talking to it with a Raspberry Pi.

CY3280

One of the team used a CYW943907AEVAL1F talking to a CY3280 Capsense talking through cloud to a Particle Photon.  I helped them with the firmware, which I will go through in detail in the next article.

Anna, The Elkhorn Creek Kentucky Great Horned Owl

This article definitely goes in the miscellaneous category.  On Wednesday night my children, Anna and Nicholas, went out canoeing on Anna’s last night home before heading to College.  They had not been gone very long when Anna came running in saying that there was an Owl (a Kentucky Great Horned Owl) on the creek bank.  We all ran out to see it… because hey,  Owls are awesome.  And sure enough.  There was an Owl on the other side of the creek, specifically a Kentucky Great Horned Owl.

We went back to the house and I started calling around to the various bird recuse organizations in Kentucky.  I finally got a really nice guy who said that it was probably a fledgling and that we should just leave it alone… which always seems to be the best course of action.  The next morning, Anna said that we should go see if the Owl was still gone.  I agreed and we went to the creek.  We didnt see it on the other side of the creek… but thought, maybe we will just canoe over there and make sure.  Once we got to the other side of the creek, we still didnt see it.  Right before we were going to go back, Anna said “Ill get out and look one time just to make sure”.  The bank is super steep on that side of the creek.  As soon as she got out she found her face to face with the Owl… who immediately went tumbling down… splash into the creek.  I am pretty sure that a Kentucky Great Horned Owl shouldn’t be swimming in the Creek.

Kentucky Great Horned Owl - they can swim

Kentucky Great Horned Owl

Kentucky Great Horned Owl

We were not exactly sure what to do next.  So I started calling Raptor Rescues… but I couldn’t get in touch with anyone.  It was clear that the bird was not nearly strong enough to do anything.  I knew that it could bite off my finger… or claw off my hand… so I threw my shirt over the bird, then scooped it into the Canoe.  The bird was clearly in a bad way, so we took it up to the house, put a hot towel over him, and tried to dry him off.

Finally, a person from the Broadbent Wildlife Sanctuary called me back.  They are Meade County Kentucky… which is a long way from my house.  But, they were sending someone to Lexington to pick up some abandoned bunny rabbits (which I thought might make a nice snack for the Owl).  She said they would come get him.  I left him covered up in a trashcan on the front porch and hoped for the best.  It definitely didn’t look good though.

Kentucky Great Horned Owl

A few hours later I got a text message from a super nice lady named Lydia who had him and was taking him to the Vet at the Broadbent Wildlife sanctuary.  She was rushing back to the hospital and hoped he would survive.

Kentucky Great Horned Owl

Friday: I was really afraid that he was dead… and almost didn’t want to know.  But I finally sent Lydia a text.  She responded that he was still alive and they had been giving him IV fluids and a feeding tube.  This was a huge relief … I asked if there anything I could do?  Money?  She said yes… this is a mostly volunteer 501-c3 organization … so I sent them a good size donation… In the name of “Anna the Elkhorn Creek Kentucky Great Horned Owl”.  Which is officially his name in honor of Anna the Kentucky college student who fished him out of the creek.  If you are rooting for him as well please send a donation to the Broadbent Wildlife Sanctuary.

Saturday:  Lydia sent me an updated picture… he still looks pretty damn bad… but hopefully he is improving.  Please cross your fingers.

Kentucky Great Horned Owl

Saturday Afternoon:  Lydia just sent me a text.  She just fed Anna the Elkhorn Creek Kentucky Horned Owl and he stood up…

IoT Bar

Its not really IoT… but good for the soul.  Have patience… I have some good stuff coming next week.

Leviton HomeKit D15S Light Switch – WICED WiFi

Summary

A couple of week ago I was in San Jose teaching a WICED WiFi programming class.  One of the bad-ass WICED Applications Engineers told me that Leviton was shipping a new Leviton HomeKit Light Switch that used WICED WiFi and Bluetooth called the Leviton DS15.  What was even cooler was the he had done a decent amount of the design with them.  So, I ordered a few of them from amazon.com to try out.  This started my normal spectacle of house-wiring that is a spiral of me shocking myself, bleeding, cussing and worst of all spilling my beer.  You would think that a guy with a degree from Georgia Tech and 25 years as a practicing engineer would know better… but props to those electricians out there as they have mad wiring skills.

The Panel

I know that it should be obvious.  Really, I do know.  But every time I start working on wiring in my house I think… “Oh I just have 1 or 2 things to do I don’t need to turn off the breaker.”  And literally every damn time, I shock the piss out of myself.  So, today I decided to turn over a new leaf and turn off the breaker.  What was interesting this time was I also decided to use my meter to make sure that the breaker was off… and today I discovered that the label on the panel in my barn is wrong.  Damn that electrician… I take back everything nice I said about electricians.  (That ugly handwriting is mine fixing the label)

electric panel

Installing the Leviton HomeKit Light Switch

I bought a bunch of the the Leviton HomeKit Decora switches from Amazon.com.  They are a normal looking paddle light switches, but they come with WiFi and Bluetooth and are compatible with Apple HomeKit.  This means you don’t need a special app on your phone to use them, and hopefully that means that the wife-factor is low enough.  (A hint for all you guys out there… if the lights don’t come on when your wife clicks them… you had better have a good couch).   Originally I had installed ZWave Light Switches in the barn as my son always leaves the stupid lights on, but I wanted to try a product that had chips in it that I work on.  Here we go:

Leviton HomeKit Light Switch

When you open the box you get the normal book worth of instructions, in 5 languages (or something).  You also get a cream colored faceplate.  The paper on the upper left of the picture shows the serial number that you scan in with the camera in the Leviton app to attach to your device to HomeKit.

Leviton HomeKit inside the box

Here is a zoom in on just the light switch.

Leviton HomeKit Light Switch

Here is a picture of the light switches in the box.  One of the things that I always struggle with is getting all of the wires to fit neatly in the box.  This box was originally done old school (only switching the hot)… which doesn’t work with these light switches.

Leviton HomeKit Light Switch Installed

Once you have the switches installed, you turn the breaker back on and run the Leviton App. The App will let you add the switch to HomeKit by scanning the numbers with your camera.

Leviton HomeKit Decora App

Once paired you can control them with the Leviton App.

Leviton HomeKit Decora App

Or with the HomeKit App.

Apple Homekit App

I did notice that there is now two generations of light switches 6 inches from where they were originally installed.   I suppose I should have cleaned that up.

Installation Aftermath

Finally… dont cry over spilled beer (actually do.. as it is a really good West 6th IPA)

West 6th IPA

 

Embedded World 2017: The Gospel of PSoC & WICED

I am back in Kentucky after an absolutely CRAZY week in Germany at Embedded World.  Looking back on the week I was extraordinarily proud of Cypress.  That was by far the best showing that we have ever had at a trade show.  And I really enjoy spreading the gospel of PSoC & WICED.  I thought that today I might post a few pictures from the week.

First, here is a picture of me delivering the benediction of PSoC & WICED at the end of my talk.

The benediction of PSoC & WICED

The day before setting up and testing the PSoC–>WICED–>Amazon–>WICED–>PSOC–>Robot ARM

Setting up the PSoC & WICED Demo

Some video from my talk… thank you RS Components

One of the Cypress 3.0 Videos

The Germans have a deep and philisophical understanding of the proper use of Pork.  Here is the meat plate at Barfüßer in Nuremberg.

Nuremberg Sausages & Pork in Nuremberg

The show was awesome… and Im glad Im home for a few days.

Embedded World 2017: WICED Controls the Secret New Chip

Summary

It is now Monday morning in Munich.  After flying all night I am here waiting for ride to the show in Nuremberg.  Saturday turned out to be a little bit stressful.  After getting the Servo Motors working correctly I tried to make the final connection between the WICED WiFI Board and the Secret New Chip board via I2C.   But that connection was not working.  Why?  I didn’t know, but all of my theories were bad e.g. does the new chip have a bug in the I2C (nope).  Finally after hours and hours of thinking about it, making logic analyzer traces, trying different boards, etc. I called my friend Greg who said “Oh, if the I2C slave stretches the clock on the 43907 I2C master, it doesn’t work. Don’t you remember that I told you that?”

Fixing the Secret Chip Firmware

The firmware fix was kind of a workaround rather than a permanent fix.  I did two things to try make sure that the new chip didnt stretch the clock.  (I am not sure that either is a guarantee).

First, I increased the speed of the I2C bus.  I doubt that this guarantees that the I2C clock is not stretched, but it seems to work.

Second, I increased the priority of the EZI2C interrupt (though I don’t think that in this case it actually mattered).  This picture shows something interesting about the new chip.  I called the BU manager and he told me that I could say that it is a multicore chip. 

Modifying the Subscriber Application

Now that I have the communication working between the WICED WiFi development kit and the secret new  chip development kit, I need to make a change or two to the Subscriber firmware to send updates to the Robot ARM controller.  One good thing about spending hours trying to figure out why the I2C was not working is that I greatly improved the Subscriber firmware.

In the modified firmware

  • Lines 330-338 setup the I2C bus interface
  • Line 337 defines a two byte buffer that will be sent each time a new message is published.  The first byte is the address in the I2C slave (in this case 0) and the 2nd byte is the value for the new position (in percent)
  • Lines 341-346 are the main loop for the new firmware.  It just waits for the semaphore in the MQTT code to be set, then it prints out the position (line 344), then sends it to the slave (line 345-346)

The last things that needs to be changed is to set the semaphore when a new message is received from the MQTT Message Broker:

  • When the message is received
  • Turn the ASCII hex value into a Integer (line 116)
  • Set the semaphore to tell the main loop to send the data (line 117)

Conclusion

Everything is done and working… and checked into GitHub.  You can find it at GitHub.com:iotexpert/emb2017.  Come see me talk at Embedded World… as always I am never sure what I will say next, which apparently makes for a good show.  Ill leave you with this image of my office, which is a total disaster area.

 

Embedded World 2017: The Top Secret New Chip as a Servo Motor Driver

Secret New Chip Driving Motor

Summary

In this article I will take you through the firmware that I will be using to control the Robot Arm Servo Motors.  The Business Unit Manager is being a total pain the neck about letting me tell too much about his new product before the announcement at Embedded World next week.  He is from Indiana, so that probably explains his dogged recalcitrance (just joking… Im from KY and there is a big rivalry).  Anyway.  You will be able to see some things about the new chip if you look closely what I am doing.  My design will have:

  • An EZI2C to support communication with the WICED I2C Master
  • Two PWMs to control two servo motors
  • A connection to the onboard switch and LED to turn the servo PWMs on/off

Building the Servo Firmware

To make the design I first create a new project and the edit the schematic.  In this new chip there is clearly some logic gates as you can see that I control the PWMs with a Toggle Flip Flop.  Basically every time I press the switch it toggles the flip flop and then either starts or kills the PWMs.  This is very handy when you are trying to figure out what is going on with the PWMs and the servos.

As in earlier Cypress chips you double click the component to configure it.  Ill start with the PWMs and observe that we have another new GUI for configuring PWMs.  The servo motors want a pulse that is between 1 and 2 ms wide at a frequency of 50hz.  My PWM has a 12 Mhz clock input, which is then divided by 4 with the prescaler, and finally by 60000 by the PWM itself.  That equation yields a period o.052 kHz which (also known as 52hz) as PSoC Creator helpfully tell us.  By setting the compare to 3000 I will end up with a pulse of 1MS (about).

Configure the TCPWM

In order to configure the PWM to have the start/kill inputs, I select the Advanced tab and setup the PWM to start when the toggle flip flop goes low.  And I get it to kill (stop) when the toggle flip flop goes high.  I choose active low because the LED that is attached to the circuit to indicate the state to the user is active low.

Advanced PWM Configuration

Next I configure the EZI2C by double clicking it.  It looks like there is a new interface for EZI2C as well… but under inspection there is nothing too tricky.

Configuring the EZI2C

Once I have the schematic built, I need to assign the Pins which is done using the DWR Pins Menu (as you did with earlier Cypress chips)

Pin Assignment

Hmmm it looks like the new chip comes in a BGA, and seems to have a bunch of pins.  For the purposes of this demo, I assign the two motor pins too two of the pins on the Arduino Adafruit Servo Shield that I am using to make the connectivity easier.  This was a neat way for me to be able to plug in servo motors and provide them with power from something other than the chip, but still drive them with the chip.  Here is a picture of my shield.

Adafruit Servo Motor Shield

Build the Firmware

The firmware is very simple.

  • Declare a structure to hold the data from the I2C master (lines 8-11)
  • Start & Configure the EZI2C (lines 21-23)
  • Start & the PWMs (lines 24-28)
  • In the main loop, when there is a complete write from the I2C Master, Update the PWM compare values
  • The function convertPercentToCompare calculates the compare value required based on a number 0-100 (aka percent)

Servo Motor Firmware

Testing the Firmware

To test the firmware I use the Bridge Control Panel to issue I2C Commands (as I did in the earlier post).  You can see that I did a list devices.  Then sent several different percents (they are in hex).

Using the Bridge Control Panel to control the Servo Motors

Here screenshot from my oscilloscope where you can see that I entered 0x32 (aka 50%) so the width of the pulse is 1.5ms @ 50Hz.

Servo Motor Pulses on Oscilliscope

And it seems to work pretty well at controlling my Servo Motor Robot ARM.  Nicholas looks a little bit crazy, probably the result of too much Solder smoke?

Nicholas and the Servo Motor Controller

In the next article I will make the final connection to the WICED WiFi kit which will give me end to end connectivity through the Amazon IoT Cloud.

Alan

p.s. I love this new chip, you guys are going to be blown away.

Embedded World 2017: PSoC CapSense –> WICED WiFi MQTT –> Amazon IoT

Summary

In a previous post I showed you how to build a CapSense GUI using the PSoC Analog CoProcessor.  And, in an earlier, post I showed you how to make a WICED WiFi MQTT Publisher App that can send data to the Amazon IoT Cloud.  Now I need to put it all together so that I can I2C read from the CapSense GUI and then publish that data to the Amazon Cloud.  In order to do that I will need to make a few modifications to the Publisher App:

  • Delay 100 ms (meaning the WICED WiFi board is I2C polling)
  • Read the I2C Register 0 on the PSoC Analog CoProcessor Board
  • If the position has changed, then Publish the new position to the Amazon MQTT Message Broker

Here is a picture of the two boards connected together.  If you have a sharp eye you probably noticed that the LED next to B0 is on.  I changed the PSoC Analog CoProcessor firmware to retain the state of the last button press.

PSoC Analog CoProcess and WICED WiFI

Modify the WICED WiFi MQTT Publisher Firmware

If you remember, the Publisher App was built to turn a light on and off when the user pressed the button on the board.  To do this, WICED MQTT Published an ASCII message of either “LIGHT ON” or “LIGHT OFF” that was stored in a char pointer called “msg”.  The original firmware also used the user button to trigger the publishing by setting a semaphore.  I want the board to poll every 100ms the current state of the button, then if it is changed from the last time, publish a message with the new position.  There are several things that need to happen to make this work

  1. Setup the I2C device: (lines 297 –> 307)
  2. Start the infinite loop (line 309)
  3. Delay 100 ms (line 312)
  4. Check to make sure that we are not in the middle of publishing.  The publishing is an asynchronous transaction. (line 314)
  5. Read the I2C register of the PSoC (line 316)
  6. If the position has changed, then setup the message and activate a publish (line 317-322)

WICED WiFi MQTT Firmware

Test the WICED and PSoC Firmware

To test the whole setup I program the board, then attach to the Amazon Cloud MQTT Test Client.  Then I use it to subscribe to the “ROBOT_POSITION” topic.  You can see in the picture below the transactions that I tested:

  • The WICED Development Kit booted
  • WICED I2C read initial position = 20 (0x14)
  • I pressed B2 and it read position =40 (ox28)
  • I pressed B2 and it read position =80 (ox50)
  • I pressed B2 and it read position =60 (ox3C)

Testing the WICED WiFi MQTT Firmware

In the next article I will modify the Subscriber application to take the published position and write it via I2C to the new super secret development kit that is controlling the Robot ARM.

Embedded World 2017: PSoC Analog CoProcessor CapSense GUI

Summary

I have been building up pieces of code that are going to allow me to show the PSoC Analog CoProcessor –> WICED WiFi –> Amazon IoT –> WICED WiFi –> Secret New Chip –> Robot Arm.   In the previous two articles (part1, part2) I have shown you how to build most of the WICED firmware.  In this article I am going to focus on the PSoC Analog CoProcessor firmware (but if you look real close you can see the secret new chip’s development kit).

In the picture below you can see the red shield board.  This is a shield with the PSoC Analog CoProcessor plus a bunch of sensors that show the power of that chip.  The shield also includes 4x CapSense Buttons which I am going to use to set the position of the Robot Arm.  The PSoC will serve as a front end companion to the WICED WiFi Development Kit.  They will communicate via I2C with the PSoC acting as an I2C Slave and the WICED WiFi as a master.  Here is a picture of the all of parts minus Amazon.com’s cloud.

Embedded World 2017 Components

PSoC Analog CoProcessor

The PSoC Analog CoProcessor has the new Cypress CapSense block that gives you a bunch of new features, including enough measurement range to measure a capacitative humidity sensor (which you can see in the upper left hand part of the board).  For this demonstration I am just going to use the 4 CapSense buttons.  They will serve as the user interface for the Robot Arm.  The 4 buttons will set 4 different positions, 20%,40%,60%,80%.  I will be talking in much more detail about this shield in coming posts (later next month)

PSoC Analog CoProcessor Schematic

The PSoC Creator schematic is pretty straight forward.  I use the EZI2C slave to provide communication for the WICED board.  There are 4x LEDs that sit right next to the CapSense buttons,  and there are the 4x CapSense buttons.  The only slightly odd duck is the Bootloadable component which I use because when I designed the shield I did not put a programmer on it.  The BootLoadable allows me to me to load new firmware into the PSoC via the I2C interface.  Here is the PSoC Creator Schematic:

PSoC Creator Schematic

The CapSense configuration just specifies the use of 4x CapSense buttons that are automatically tuned by the Cypress magic.

CapSense Configuration

The last step in configuring the schematic is to assign all of the pins to the correct locations.

Pin Assignment

PSoC Analog CoProcessor Firmware

One of the great things about all of this process is how easy the firmware is to write.

  • Line 3 declares a buffer that will be used to relay the position information to the WICED board.  I start the position at 50%
  • Lines 8-9 start the EZI2C which starts up the EZI2C protocol and tells it to read from the “position” variable
  • Lines 10-11 gets the CapSense going

Inside of the infinite while(1) loop, I read from the CapSense and do the right thing

  • Lines 17-22 reads the CapSense status
  • Lines 24-27 set the correct position based on which buttons are pressed (notice that if no button is pressed then the position stays the same)
  • Line 29 turns on the Bootloader if B0 & B3 are pressed

PSoC Analog CoProcessor Main.c

Testing the PSoC Analog CoProcessor System

The easiest way to test the system is to use the Bridge Control Panel which comes as part of the PSoC Creator installation.  It lets me read the value from the EZ2IC buffer to make sure that the CapSense buttons are doing the right thing.  The command language is pretty simple.  You can see in the editor window that I typed “W42 0 R 42 X p;”  Everytime I press “enter” it sends the I2C commands:

  • Send an I2C start
  • write the 7-bit I2C address 0x42
  • write a 0
  • send a restart
  • read from address 0x42
  • read one byte
  • send a stop

You can see that I pressed each button and indeed got 20,40,60,80 (assuming you can convert hex to decimal… but trust me)

Bridge Control Panel

In the next article I will modify the WICED Publisher to poll the PSoC Analog CoProcessor and then publish the current state.

Embedded World 2017: WICED WiFi, MQTT and the Amazon IoT Cloud (Part 2)

Summary

As I explained in yesterday’s article, I was unhappy about not connecting to Amazon AWS IoT cloud for my presentation at Electronica 2016.  In the last post I showed you how to build an Amazon AWS IoT MQTT Client in the WICED WiFi SDK that can Publish to the Amazon Message Broker.  Now I need to build a WICED App that can Subscribe to the ROBOT_POSITION topic and receive messages from the MQTT broker.  This series of articles is broken up like this:

  1. Amazon IoT & MQTT (Part 1)
  2. Modify & Test the WICED Publisher App (Part 1)
  3. Modify & Test the WICED Subscriber App (Part 2)
  4. Modify the Application to talk I2C to the PSoCs (Part 3)

Modify the WICED Subscriber App

As with the previous article, start by copying the App from the apps–>demo–>aws_iot–>pub_sub–>subscriber into your directory.  In my case that will be apps–>emb2017–>subscriber.  Then update the application “Name:” and “VALID_PLATFORMS” in the Makefile.  Remember that the App name must be unique.

WICED WiFi SDK

Then modify the DCT to have your networking information.  Don’t forget that the DCT is the device configuration table for WICED WiFi and is used to store the mostly static information (like network, passwords etc).

WICED WiFi Subscriber DCT

The next step is to make a few modifications to the actual firmware.  Specifically,

  • (line 60) Change the MQTT Broker IP address to the one assigned by Amazon
  • (line 61) Change the TOPIC to “ROBOT_POSITION”
  • (line 103) Print the message to the console

subscriber.c

In the last article I copied the Transport Layer Security (TLS) keys from Amazon into the resources–>apps–>aws_iot directory.  For this application I will use exactly the same keys.  Then, create a new make target for the App and program the board.

WICED WiFi Make Targets

Test the WICED WiFi Subscriber App

To test the application I will, once again, use the Amazon AWS IoT web MQTT Client to send messages to my board.  In the screen shot below you can see the console window of the 943907AEVAL1F board.  After programming it:

  • starts up
  • gets WICED and ThreadX going
  • connects to my network (WW101WPA, gets a DHCP address: 198.51.100.16)
  • Find the IP address of the MQTT broker (34.194.80.220)
  • Opens an MQTT connection to Amazon.

When I publish the message “20304050” using the MQTT Client to the “ROBOT_POSITION” topic,  you can see that it comes out on the console of the WICED WiFi development kit.

Amazon IoT MQTT Test Client

That proves that we have end-to-end communication.  In the last article, I will fix up the Publisher and Subscriber application to read and write the I2C connection so that it can actually do the Robot ARM control.

Embedded World 2017: WICED WiFi, MQTT and the Amazon IoT Cloud (Part 1)

Summary

As I explained in yesterday’s article I was unhappy about not connecting to Amazon AWS IoT cloud for my presentation at Electronica 2016.  In this article I will start this process of repairing the my brain damage by taking you through the steps I am following to create an MQTT connection to Amazons cloud using WICED WiFi.  I will post 3 articles on this topic:

  1. Amazon IoT & MQTT (Part 1)
  2. Modify & Test the WICED Publisher App (Part 1)
  3. Modify & Test the WICED Subscriber App (Part 2)
  4. Modify the Application to talk I2C to the PSoCs (Part 3)

PSoC AFE & WICED WiFi

Amazon IoT & MQTT

The Amazon IoT Cloud can do an amazing, frightening, crazy overwhelming amount of different things.  Here is a picture of their architecture.Amazon IoT Architecture

Above, you can see that Amazon has decided to follow on the language of IoT by actually calling the devices that attach to their cloud “Thing”.  This makes for some rather awkward English sentences, but I suppose they are not going to change it, so I will go with their language.  For the purposes of this demonstration I am going to create two “things”.  One will be “Publisher” and one will be the “Subscriber”.  The “Things” will attach and communicate to each other via the Message Broker in the Amazon Cloud.  The connection will be built in the WICED SDK using MQTT and run on the Cypress CYW943907AEVAL1F development kit.

MQTT stands for Message Queuing Telemetry Transport, which, in simplest terms is a lightweight TCP/IP based protocol that can run over secure sockets.  The good news is the Cypress WICED SDK has MQTT built in and provides a clean interface for you to develop firmware to create and use MQTT connections.  MQTT is pretty simple and has only four important concepts.

  • Message Broker – A server that supports MQTT connections and hosts Topics
  • Topic – The name for a queue of Messages (the Topic name can essentially be anything that you want in your system)
  • Message – A string of bytes in any format you desire for your system
  • Publisher – A device that sends a Message to a specific Topic on a specific MQTT Message Broker
  • Subscriber – A device that has asked to receive Messages sent to a specific Topic

For the purposes of this demonstration I will create a Publisher (running on the 943907AEVAL1F board) that will publish a message with the desired position of the servo motors on the robot ARM to a Topic (named ROBOT_POSITION) on the Amazon Message Broker.  The Subscriber (running on a different 943907AEVAL) will subscribe to the Topic and will then send an I2C command to the PSoC controlling the Robot ARM.  For example if the 4 CapSense buttons B0-B3 represent 10%, 30%, 50%, 70%, 90% then when the users presses B0, WICED will publish a message of “10” to the Topic “ROBOT_POSITION”.  Then, that message will go to the Subscriber, who will send that message to the PSoC Servo Motor controller.

In order to make the connection to the Amazon IoT Cloud you need to use Transport Layer Security which is also built into the WICED SDK.  Good security is one of the best reasons to use Cypress WICED as we are taking that very seriously.

The AWS IoT Cloud supports a bunch of other functionality including:

  • Connections to the Dynamo DB
  • Simple Notifications (Text message, Email)
  • Running Lambda Functions
  • Plus a bunch more

However, all of that is outside of the scope of what I have time to show live.

WICED WiFI: Modify & Test the Publisher App

To build the application, I will copy and modify, then test the Publisher Demo App.  In order to simplify things I will use the pre-exising App that already has all of the MQTT stuff in it.   Cypress provide a bunch of example applications which all reside in the “apps” folder of the Project Explorer.  So, I will start by creating a directory called “emb2017”.  Then I will copy/paste the apps–>demo–>aws_ios–>pub_sub–>* into my emb2017 directory.

WICED WiFI Project Explorer

The next step is to modify publisher.mk file:

  • Make the “Name” unique.  Each application name must have its own unique name or your firmware will not build correctly.  In this case I name it  “App_emb2017_Publisher”
  • Add BCM943907AEVAL1_WW101 to the valid platforms list.  A platform is the WICED name for the Board Support Package.  In this case we create a BSP for the PSoC Analog AFE Shield.

WICED WiFI Makefile

After the Makefile is fixed up, I will need to modify the Device Configuration Table (aka wifi_config_dct.h) so that it knows about the network at my house.  The DCT is an area of flash that is used to hold security credentials, network SSIDs etc.  This place can be configured either statically at build time or programmatically at run time.  In this case, I will just set the SSID/Password at build time.   For this example I will use the WW101WPA” network which is a pre-shared key WPA2 network with a password of “kywpa123” (Yes, if you come to my house in KY you will be able to attach with that password.  If you do, please knock on the door and we can have some Bourbon together).

WICED WiFI DCT Configuration File

In order to make a TLS connection you will need to have three files:

  • rootca.cer – Amazon’s Root Certificate
  • privkey.cer – A private key (paired with a public key) that will allow you to establish a secure connection
  • client.cer – A certificate that identifies your AWS “Thing”

Amazon IoT Security

All of these files come from the Amazon IoT website and need to be copied into the “…/resources/apps/aws_iot” directory.  They will be compiled along with your application and placed into the DCT of your WICED device by the Makefile.  This happens as a result of this section of the Makefile:

WICED WiFI Configuring Security in the DCT

The next step in the process is to modify the publisher.c program.  When you setup an Amazon IoT account, it will create a virtual machine with the Message Broker running on it.  That VM will be given a unique name which you will need to hard code into your application.  In addition you need to change the topic and message sent.  Here are the changes that I made to publisher.c:

WICED WiFI modify MQTT publisher.c

Now that all of the Firmware is setup, I need to program the board.  To do that I create a new “Make Target” in the WICED Make Target window. The make target tells the makefile system:

  • Which app to build, in this case “emb2017/publisher”
  • Which platform to use.  Platform == Board Support Package.  In this case “bcm943907EVAL1F”
  • Lastly what to do, in this case build, download and run

WICED WiFI Create the Make Target

The last thing to do is program the board and then test using the Amazon IoT MQTT WebClient.  This client can subscribe and publish to your Message Broker.  Our application is configured to Publish to the “ROBOT_POSITION” topic.  So, I will subscribe to that Topic, which will cause all messages that are published to that topic to be displayed.  This happens when I push the Mechanical Button 0  the PSoC AFE Shield

Amazon IoT MQTT Client Test Console

In the screen shot below you can see the console of my 943907AEVAL1F board as well as the MQTT Test Console.  The board starts by turning on WICED, starting the RTOS, turning up the TCP/IP stack, then attaching to the network etc.  After all of that is done it starts an MQTT connection to the Amazon IoT MQTT broker.

On the AWS MQTT client, you can see that I pressed the button three times which published three messages.

WICED WiFI MQTT Publisher Test

In the next Article I will take you through the creation of the Subscriber side of this application.

Embedded World 2017: Uh oh I Only Have 4 Days to Get Ready

Embedded World 2017: Summary

I will be at Embedded World 2017 in Nuremberg, Germany next week.  For some crazy reason the powers that be at Cypress seem to think that it is a good idea to hand me a microphone.  For the last several trade shows I have done live demonstrations of Cypress chips, which seem to get a pretty good crowd.  Here is a video of me talking at Electronica 2016:

https://www.youtube.com/watch?v=bXCnE4wLl_Q

Here I am two years ago at Embedded World 2015.  Unfortunately there were more people there watching me talk than have viewed this video!

Over the next couple of days I will post the pictures, schematics and source code for the projects that I will be showing.  If you are there you should definitely come see me as I give a good Ginsu Knife show… and I will be giving away development kits.  Best of all there is a new chip coming that I am going to get to show off … a very remarkable IoT offering that will put us in the lead (and if you are reading this you will get some early insight into).

At Electronica last fall I showed I showed Cypress PSoCs doing CapSense and Servo Motor Control over a WICED WiFi link.  You can read about that stuff here.  It was a really good demonstration, and everyone thought that was fun, but I always regretted that I didn’t send the data to the cloud.  Here is a picture of the architecture  that I was planning to build for that show, but I cut out the trip to Amazon AWS and replaced it with a TCP/IP Server running on the WICED chips:

Embedded World 2017: Demo Architecture

This time I am going to go all the way.  In addition there will be a Development Kit for a new product that we are announcing at the show.

The bottom line… for this live demonstration of Cypress awesomeness I am going to use

  1. The CYW943907AEVAL1F WiFi board as connectivity to the Amazon Cloud.WICED 943907AEVAL1F
  2. The Top Secret new development kit with a really fun new chip that we have all been waiting for  (notice the Type-C connector, Mutal Cap Capsense Sensors, that might be an antenna at the top and for sure there is something cool under that post-it-note)A amazing new Cypress Development Kit
  3. The Cypress Analog CoProcessor AFE Shield Board… which I will be talking more about in future posts, but is built with the PSoC Analog CoProcessorCypress PSoC Analog CoProcessor
  4. The CY8CKIT-145: As a CapSense User Interface Cypress CY8CKIT-145

Over the next 3 days Ill post the intermediate steps of building the project.  I am flying to Embedded World 2017 on Sunday so I am going to need to get rolling.

IoT Expert in Shenzhen: Seeed Studio

Seeed Studio

On Wednesday before the flight to Shanghai we decided to see if we could find Seeed Studio.  They are a Chinese Maker company ala Adafruit.  I started by “googling” Seeedstudio to try to figure out where they were… but in China there is no Google.  So I bing-ed … then on their website found the location.  I took a picture of my screen to show to the taxi driver.

After a 30ish minute taxi ride, we were dropped off in front of a security gate.  I “talked” to the security guard (who spoke as much English as I speak Chinese).  After a few minutes of wild gesturing, he signaled us to follow him… to the entrance of SeeedStudio.

Entrance to Seeed Studio

There was someone standing out front who spoke English.  He led us into the office.  They were at lunch, but asked us to sit and wait, which we did.  After a while they brought out the International Product Manager.  I introduced myself as a Cypress person.  We talked for a while about ideas for cooperation between our companies.  Then they took us on a tour.   Here are a few pictures.  First, the workshop:

For some reason they didnt label their boxes 🙂

Then out in the engineering area:

Finally goodbye:

IoT Expert in Shenzhen: Huaqiangbei Electronics Market

Summary

This week I am in Shenzhen, China teaching Cypress and Distribution Engineers how to program WICED WiFi.  I thought that while I was here I should go see the crazy electronics and maker scene.  So,  my friend Greg and I headed off to Huaqiangbei Electronics Market (华强北), then SeeedStudio (the subject of the next post)

Huaqiangbei Electronics Market

Last week I wrote an article about using hot-air rework tools to fix screwed up PCBs.  As I walked around, I wasn’t really sure what to expect, but I surely didn’t expect to find tons of little shops with hot-air-tools fixing cellphones (and other unknown things).   In fact over the next several hours I ran into bunches of hot-air-tools… and bunches people who Im quite sure knew how to use them.

After wandering around a bit, we found the Huaqiangbei Electronics Market.  This place is a giant 8-9-10 floor electronics bazar where as best I could tell you could buy almost any electronic component you could possibly desire.  It was full of little booths selling everything you could imagine, from cellphones to PCs to reels of 0603 resistors.

One of the first floors of the place was little (like 15×15 feet) shops selling LEDs.

Here is some dude bagging up and heat shrinking bunches of through-hole LEDs.

And another booth selling LEDs

Everywhere you looked there where booths over flowing with components.  Here is a booth with some Rupees.. and transistors.

I dont know how you would find ANYTHING with booth after booth overflowing with reels and reels of of surface mount parts.  I suppose that it would help to know what the Chinese characters on the top of the case said.

Hey! Where the hell is the Cypress logo?

More craziness.

Here is a place selling industrial cameras.