Tag Archives: Inside Look

Digging into the Juicebox

Since the Juicebox is open source we can pull back details about the design and poke around. In this post I’m going to give a look-see through the source code running on the Arduino¬†board that runs the Juicebox.

The Juicebox code is a very simple loop running on the Arduino (an ATmega328P microcontroller equivalent). There is no RTOS running on the Arduino–just the Juicebox code. There really isn’t enough room on the chip to have a full RTOS; there is barely enough room there for the code that is running on it.

During setup/startup the code configures the Juicebox:

  • Configure I/O
  • Setup timers
  • Check for and Initialize display
  • Read the last clock value out of EEPROM (there is no real-time clock on the board so it remembers the last time it was powered up)
  • If the “A” button on the remote is pressed all the configuration parameters are reset to default
  • Checks for the presence of the remote (not sure why this is after the above check)
  • Calibrate the pilot signal: It will adjust the pilot signal based on temperature and voltage output
  • Determine the input voltage (120V or 240V)
  • Perform some diagnostics on the GFI circuitry

Now its finally ready to go. You can pretty much see/hear this sequence being performed when the Juicebox is first plugged in as it takes about 10 seconds or so to get through it all.

The main section of code is just a large loop. The loop repeatedly cycles through the following tasks:

  • Check for presence of a car and if it is charging
  • Manage a change in state from the previous iteration through the loop (e.g. car plugged in, car charging, charging complete, etc.)
  • Set the configuration to the new state (if changed)
  • Update the display (real-time status on charging)
  • If there is WiFi send some data out to the Web (EMW)
  • Check if a menu button has been pressed
  • Check if the GFI has tripped
  • Repeat

That is about it. Pretty simple operation but then I really wouldn’t expect a lot from an EVSE since it really has only two purposes: Provide power to the car and provide GFI protection.

One feature that I’d like to see in the Juicebox that it currently doesn’t do: Turn off the display after 5-10 minutes when not plugged into the car. There really is no reason to keep the display lit when not plugged in. (I’m not sure if this is even possible simply by looking at the source code–may have to take a peek at some circuit diagrams to figure that one out.)