When cooling beer we want to store history of temperatures for two reasons. First, it gives us valuable history data for next cooling sessions. As a second thing we can ask measurements when we temporarily lost connection with IoT Hub. In this posting we make some analyzis and then build up database for our beer cooling solution.
- Beer IoT: Measuring temperature with Windows 10 IoT Core and Raspberry Pi
- Beer IoT: Moving to ITemperatureClient interface
- Beer IoT: Measuring cooling rate
- Beer IoT: Making cooling rate calculation testable
- Beer IoT: Estimating beer cooling time
- Beer IoT: Reporting measurements to Azure IoT Hub
- Beer IoT: Using Stream Analytics to save data from IoT Hub to SQL database
- Beer IoT: Visualizing sensors data using Power BI
- Beer IoT: Building Universal Windows Application to monitor cooling process
Update. Source code of my TemperatureStation solution is available at Github. The solution contains IoT background service and web application you can use right away. Readings are reported to MSSQL or Azure IoT Hub. Documentation is available at TemperatureStation wiki. Feel free to try out the solution.
Creating SQL Azure database
I’m sure I want to brew eisbock more than once and therefore I have more than one cooling session coming. As all these sessions introduce data I want to store I need something to find out what measurements belong to what cooling session. In this point I introduce new term – batch. In brewing batch mean the concrete brew in container.
So, in total we need two tables:
- Batch – batch key, measuring state, cooling rate and device used for measuring,
- Measurement – batch key, timestamp, beer temperature, ambient tempereture.
Here is database diagram. Although we expect currently the ambient temperature to be constant this doesn’t hold always true and in the future I also want to consider situations where ambient temperature is changing (it’s important in spring and autumn when cooling takes longer due to less frost).
SQL script to create these two tables is here. This SQL works on Azure SQL too, so just create database there, take this script with copy-paste and run it.
CREATE TABLE [dbo].[Batch] ( [BatchKey] NVARCHAR (15) NOT NULL, [DeviceId] NVARCHAR (15) NOT NULL, [CoolingRate] FLOAT (53) CONSTRAINT [DF_Batch_CoolingRate] DEFAULT ((0)) NOT NULL, [IsActive] BIT CONSTRAINT [DF_Batch_IsActive] DEFAULT ((0)) NOT NULL, CONSTRAINT [PK_Batch] PRIMARY KEY CLUSTERED ([BatchKey] ASC) ) GO CREATE TABLE [dbo].[Measurement] ( [Id] INT IDENTITY (1, 1) NOT NULL, [BatchKey] NVARCHAR (15) NOT NULL, [Time] DATETIME NOT NULL, [BeerTemp] FLOAT (53) NOT NULL, [AmbientTemp] FLOAT (53) NOT NULL, CONSTRAINT [PK_Measurement] PRIMARY KEY CLUSTERED ([Id] ASC), CONSTRAINT [FK_Measurement_Batch] FOREIGN KEY ([BatchKey]) REFERENCES [dbo].[Batch] ([BatchKey]) ) GO
Now we have simple SQL Azure database where we can save measurements data.
Getting data from Azure IoT Hub to SQL database
Now comes the most complex part of this show. We have to get data reported to IoT hub to SQL Azure database and we don’t want to write any code for this. Also we don’t want to write all data to database because temperature changes are not rapid and taking averages over some small time window help us keep database smaller without loosing any important information.
Here’s the full path for measurements to get from device to SQL database.
Stream Analytics is Azure service for real-time data processing and aggregating. All Stream Analytics queries are run in some time window on data that is flowing in. Stream Analytics takes data from inputs, processes it and then sends to outputs, In our case Azure IoT Hub is input and SQL database is output.
Creating Stream Analytics job
Now go to Azure portal and create new Stream Analytics job.
Adding input
When new Stream Analytics job is created you are redirected to main page of Azure portal. Browse to newly created Stream Analytics job, open it and click on Inputs box. This opens inputs list on right. Click there on Add button.
To “IoT Hub” field insert the subhost name part of your IoT Hub address. If your IoT Hub address is something.azure-devices.net then the value on “IoT hub” field must be “something”.
For shared access policy I took “service” and to shared acces key field you have to insert the key from this policy. You can find the policy key from IoT Hub settings. Just open settings in Iot Hub, select “Shared access policies” and then “service”. From policy properties window copy the value from field “Primary key” and paste it here.
When data is inserted and user saves it then Azure portal checks if new input source can be connected. Just wait some moments after clicking Save button to see if input source is okay.
Adding output
To “Database” field insert the name of the database you created before.
To “Server name” field insert your database server address. For SQL Azure the address is like something.database.windows.net. If you have database hosted by your own or if you are running SQL Server on Azure virtual machine then insert here the IP of your server because you don’t have any access to DNS servers used by Azure.
User name and password should be obviuos so skip them. Last field is Table and to this field write Measurement.
Now we have all data inserted and it’s time to save. Click “Create” to save database as new output source.
The names you gave to input and output sources are the ones you will use later when writing Stream Analytics queries. So choose these names carefully and make sure they make sense. It makes it easier to understand queries later.
Creating Stream Analytics query
As a last thing we have to add query that is run on incoming data flow. As Azure new portal doesn’t support testing of Stream Analytics queries yet we have to switch to old management portal and insert query there.
Now things get a little bit tricky because the query must know input and output formats. On input side we have data that is structured like our measurement objects we are sending out from device. On output side we have measurements table we created above. Additionally we have to define aggregates on all numbers in our query.
Now we have one additional problem. Stream Analytics query is running on data that is coming in from data source. Currently the data we are sending to Azure IoT Hub doesn’t have information about what batch it is and there’s no way on Stream Analytics side to make the decision. We have to add batch key to data transfer object we are using to send data to Azure IoT Hub.
We add new batchKey attribute to anonymous DTO we are using in ReportMeasurement method.
private void ReportMeasurement(DateTime time, double beerTemp, double ambientTemp, double estimate) { var beerMeasurement = new { deviceId = "MyDevice", batchKey = "Eisbock-1", timeStamp = time, beerTemp = beerTemp, ambientTemp = ambientTemp, estimate = estimate }; var messageString = JsonConvert.SerializeObject(beerMeasurement); var message = new Message(Encoding.ASCII.GetBytes(messageString));
Now we can go on and write a query that saves data to SQL Azure database. Here is the Stream Analytics query.
SELECT batchKey as BatchKey, MAX(CAST([timeStamp] AS datetime)) as Time, AVG(beerTemp) as BeerTemp, AVG(ambientTemp) as AmbientTemp INTO [SqlAzureBeerIoT] FROM [FromIoTHub] GROUP BY batchKey, TumblingWindow(minute, 5)
Some notes. We cast timestamp field to datetime because otherwise Stream Analytics considers it as something that should be casted to float. Not sure why it is so. As we are interested in temperatures during five minutes time windows (called also as tumbling window) we take averages of temperatures reported.
Once we run Stream Analytics job we can’t make changes there. To change something we have to stop the job and then do our modifications.
Adding first batch to database
Before we can start gathering data we need at least one batch to be available in Batch table. Add new batch with following data:
BatchKey: Eisbock-1
DeviceId: MyDevice
IsActive: 1
After adding this row to Batch table we are ready to run to test if data gets from IoT Hub to SQL Azure database.
Testing Stream Analytics job
Now run Stream Analytics job and open your IoT Hub so you see its dashboard. Also open your database in SQL Server Management Studio and be ready to make select from Measurement table. Run beer cooling solution and see if data starts coming. To SQL Azure data comes with some delay. It depends on how wide is data window over what we are aggregating the results.
If everything is okay then soon you shoud see new data in Measurement table. If time window is five minutes then you should wait at least five minutes before you see any data.
Wrapping up
This was long post full of analyzis and configuring of services but we made it and now our data is flowing from IoT Hub to SQL Azure database. As we are aggregating measurement results over time windows of 5 minutes we store less data than is coming in but still we don’t loose much and for next batches we have useful historical data to take.
View Comments (369)
nice article. thanks
Thank you again for this reference. I found it extremely helpful for a project of mine. :)
https://jekyll.s3.us-east-005.backblazeb2.com/20241220-15/research/je-tall-sf-marketing-(280).html
A classic night dress with the right neckline, colors,
and sleeve length will add to your ultimate outfit.
https://je-sf-tall-marketing-502.b-cdn.net/research/je-tall-sf-marketing-(333).html
Peach, crimson, and gold brought punchy color to a traditional
Indian sari.
https://marketing-229.b-cdn.net/research/marketing-(33).html
It’s often widespread follow to keep away from carrying white, ivory
or cream.
https://jekyll.s3.us-east-005.backblazeb2.com/20250219-2/research/je-tall-sf-marketing-(262).html
Another gown with ruching for you as I think ruched types are so flattering.
https://jekyll.s3.us-east-005.backblazeb2.com/20241101-2/research/je-tall-sf-marketing-(373).html
Keep in mind that many websites allow you to filter
attire by shade, silhouette, size, and neckline.
https://jekyll.s3.us-east-005.backblazeb2.com/20241121-20/research/je-tall-sf-marketing-(411).html
The knotted entrance element creates a fake wrap silhouette accentuating the waist.
https://jekyll.s3.us-east-005.backblazeb2.com/20241113-19/research/je-tall-sf-marketing-(180).html
A classic evening costume with the best neckline,
colors, and sleeve size will add to your final outfit.
https://digi50sa.z1.web.core.windows.net/research/digi50sa-(412).html
It’s your duty to grasp what she needs from both you and the groom’s mom in phrases of your
apparel.
https://je-tall-sf-seo-29.research.au-syd1.upcloudobjects.com/research/je-tall-sf-seo-1-(71).html
Pink anemones and blue and yellow wildflower buds accented this beautiful black gown worn by
the mother of the bride.
https://storage.googleapis.com/digi105sa/research/digi105sa-(473).html
Even as a visitor to a wedding I even have made a few mistakes in the past.
https://objectstorage.ap-tokyo-1.oraclecloud.com/n/nrswdvazxa8j/b/digi28sa/o/research/digi28sa-(234).html
Impressive beading and an alluring neckline make this style worthy of even the fanciest of
black-tie weddings.
https://je-tall-sf-marketing-71.nyc3.digitaloceanspaces.com/research/je-tall-sf-marketing-(38).html
Browse through the new assortment of Mother of the Bride robes 2021.
https://classic-blog.udn.com/e0ed808c/182729531
The capelet costume is good should you like to cowl up your higher arms.
https://marketing-all-business.s3.us-east-005.backblazeb2.com/20250512-8/research/cz-marketing-(219).html
Similar to the moms of the bride and groom, the grandmothers might want to coordinate with the wedding party.
https://classic-blog.udn.com/b16a7255/182747131
Look and feel truly elegant in this lengthy costume without stealing all the attention from the bride.
https://jekyll2.s3.us-west-002.backblazeb2.com/je-20250505-32/research/marketing-(470).html
So earlier than I even go into element mother of the bride outfit ideas, I wish to emphasize one necessary thing.
https://cz-marketing-198.b-cdn.net/research/cz-marketing-(336).html
But for others, it’s restrictive, it feels too formal, and
infrequently, it ends up being somewhat
costly too.
https://cz-marketing-455.syd1.digitaloceanspaces.com/research/cz-marketing-(123).html
When first starting to plan your mother of
the bride outfit, look to the wedding location itself for inspiration.
https://digi591sa.netlify.app/research/digi591sa-(115)
My daughter goals of a marriage on a seaside in Bali, so where will that depart me I marvel.
https://digi595sa.netlify.app/research/digi595sa-(335)
Make a gorgeous impression on this floral printed ball robe featuring wrap-around ties
that spotlight your waist and helpful hidden pockets.
https://cz-marketing-347.b-cdn.net/research/cz-marketing-(393).html
Take this easy but fashionable knee-length wedding
ceremony visitor costume for the mother-of-the-bride.
https://digi332sa.netlify.app/research/digi332sa-(240)
Frumpy, shapeless mother of the bride dresses are a thing of
the past!
https://je-tall-sf-seo-56.b-cdn.net/research/je-tall-sf-seo-1-(348).html
Make sure you’re each sporting the same formality of costume as well.
https://classic-blog.udn.com/dfa7e8c0/182851678
With over 1,868 5 star reviews and coming in properly underneath $100, this Gatsby fashion Maxi robe
is bound to impress.
https://je-tall-sf-marketing-32.fra1.digitaloceanspaces.com/research/je-tall-sf-marketing-(80).html
But I will not select any of the outfits you've shown.
https://digi619sa.netlify.app/research/digi619sa-(252)
Sophie Moore is a former Brides editor and present contributing writer.
https://digi608sa.netlify.app/research/digi608sa-(301)
Go for prints that speak to your marriage ceremony location,
and most importantly, her personal type.
https://je-tall-sf-marketing-116.ams3.digitaloceanspaces.com/research/je-tall-sf-marketing-(53).html
From the floor-sweeping A-line skirt to the on-trend off-the-shoulder sleeves, there's lots to like.
https://digi15sa.sfo3.digitaloceanspaces.com/research/digi15sa-(233).html
It’s available in three colors and in sizes 0-18 and will be perfect for summer, vacation spot, and bohemian weddings.
https://filedn.eu/l46Ju9IQhhQ84ifWoIzEYnJ/digi78sa/research/digi78sa-(345).html
With over star critiques, you can be certain this dress will exceed your (and
your guests!) expectations.
https://jekyll.s3.us-east-005.backblazeb2.com/20241015-13/research/je-tall-sf-marketing-1-(439).html
Make it pop with a blinged-out pair of heels and matching equipment.
https://digi205sa.netlify.app/research/digi205sa-(482)
You can purchase lengthy sleeves, a protracted lace mother of the bride dress,
or a lovely ballgown with a boat neckline.
https://objectstorage.ap-tokyo-1.oraclecloud.com/n/nrswdvazxa8j/b/digi494sa/o/research/digi494sa-(441).html
As a mother, watching your son or daughter get married might be
one of the joyful experiences in your life.
https://storage.googleapis.com/digi149sa/research/digi149sa-(468).html
You ought to keep in mind the formality, theme, and decor colour of the marriage while on the lookout
for the dress.
https://digi607sa.netlify.app/research/digi607sa-(167)
As the mom of the bride, your role comes with massive duties.
https://je-tall-sf-marketings-139.b-cdn.net/research/je-tall-sf-marketing-(434).html
Next, think about what silhouettes work finest in your body kind and
what options you need to spotlight.
https://digi606sa.netlify.app/research/digi606sa-(56)
Always think about the sorts of sleeves and straps you ought to have in your costume.
https://digi631sa.netlify.app/research/digi631sa-(12)
Of course, you can play with colours of sequin outfits to kick off the
look of your desires.
https://digi264sa.netlify.app/research/digi264sa-(318)
You can still embrace those celebratory metallic shades without overlaying yourself head to
toe in sequins.
https://digi344sa.netlify.app/research/digi344sa-(463)
Now, I simply need to remember all this when my son will get married.
https://digi565sa.z45.web.core.windows.net/research/digi565sa-(277).html
Even as a guest to a marriage I even have made
a few errors prior to now.
https://je-tall-sf-marketing-43.sgp1.digitaloceanspaces.com/research/je-tall-sf-marketing-(378).html
On the opposite hand, If you are curvy or apple-shaped,
versatile costume types like a-line and empire waist will work wonders for you.
https://digi643sa.netlify.app/research/digi643sa-(458)
Look for gown options that least complement the marriage theme colors with
out blending in too much.
https://objectstorage.ap-tokyo-1.oraclecloud.com/n/nrswdvazxa8j/b/digi12sa/o/research/digi12sa-(71).html
As a mom, watching your son or daughter get married might be some of the
joyful experiences in your life.
https://digi612sa.netlify.app/research/digi612sa-(396)
Embellished with beautiful ornate beading, this robe
will catch the light from every angle.
https://digi589sa.z29.web.core.windows.net/research/digi589sa-(332).html
Whether you might have your coronary heart on embroidery,
embellishment, sequin, or ruched silk smoothness, golden clothes look
great in all kinds and designs.
https://digi607sa.netlify.app/research/digi607sa-(367)
But I is not going to select any of the outfits you've proven.
https://digi592sa.z11.web.core.windows.net/research/digi592sa-(378).html
Mother of the bride attire needn't feel frumpy or overly conservative!
https://digi637sa.netlify.app/research/digi637sa-(199)
With palm leaf décor and plenty of vines, green was a major
theme all through this charming and colorful South Carolina celebration.
https://digi594sa.z12.web.core.windows.net/research/digi594sa-(368).html
As versatile as is elegant, this icy blue frock is the
proper transition piece to take you from the ceremony to the reception.
https://digi590sa.z7.web.core.windows.net/research/digi590sa-(177).html
Jovani Plus size mother of the bride attire suits any body sort.
https://digi150sa.netlify.app/research/digi150sa-(374)
We're in love with the muted florals on this romantic mother-of-the-bride gown.
https://digi642sa.netlify.app/research/digi642sa-(22)
Think in regards to the colours you feel best in and the kinds of outfits that make you shine.
https://digi596sa.z44.web.core.windows.net/research/digi596sa-(491).html
Pink anemones and blue and yellow wildflower buds
accented this pretty black dress worn by the mother of the bride.
https://je-tall-marketing-802.fra1.digitaloceanspaces.com/research/je-marketing-(27).html
This mom of the bride wore a white tunic and skirt for a boho-chic ensemble.
https://je-tall-marketing-822.sgp1.digitaloceanspaces.com/research/je-marketing-(430).html
Take this straightforward but stylish knee-length wedding ceremony visitor gown for the mother-of-the-bride.
https://je-tall-marketing-802.fra1.digitaloceanspaces.com/research/je-marketing-(78).html
It has over 140 positive evaluations, many from women who wore this to a marriage and beloved it!
https://je-tall-marketing-794.fra1.digitaloceanspaces.com/research/je-marketing-(8).html
Some ladies favor to wear a costume, whereas others prefer separates…and each are nice
options!
https://je-tall-marketing-811.fra1.digitaloceanspaces.com/research/je-marketing-(422).html
Add a pop of colour with stylish cranberry tones and
usher in metallic touches with gold.
https://digi592sa.z11.web.core.windows.net/research/digi592sa-(461).html
Plan well in advance, so you'll not get too confused and can help both your son or daughter with the marriage preparations.
https://je-tall-marketing-782.fra1.digitaloceanspaces.com/research/je-marketing-(377).html
If you are a Nordstrom regular, you'll be pleased to know the beloved
retailer has an intensive collection of mother-of-the-bride attire.
https://je-tall-marketing-798.blr1.digitaloceanspaces.com/about/
This mom of the bride wore a white tunic and skirt for a boho-chic ensemble.
https://je-tall-marketing-801.sgp1.digitaloceanspaces.com/research/je-marketing-(274).html
A mid-length cocktail dress is an efficient way
to realize a chic look.
https://je-tall-marketing-821.syd1.digitaloceanspaces.com/research/je-marketing-(212).html
Cream is another option or skirt and top in a black and white
mixture.
https://je-tall-sf-marketing-246.b-cdn.net/research/je-tall-sf-marketing-(73).html
The whole look was the right match for the couple's tradition-filled day.
https://je-tall-marketing-811.fra1.digitaloceanspaces.com/research/je-marketing-(247).html
The thing in regards to the gold hue is that it's naturally attractive!
https://digi640sa.netlify.app/research/digi640sa-(20)
A neat shift gown that sits below the knee, a tailor-made jacket, and some type
of fussy fascinator or royal wedding-worthy hat.
https://digi645sa.netlify.app/research/digi645sa-(483)
Oleg Cassini, exclusively at David's Bridal Polyester, spandex Back zipper;
absolutely lined Hand wash Imported.
https://je-tall-marketing-788.lon1.digitaloceanspaces.com/research/je-marketing-(47).html
At as quickly as easy and refined, this superbly draped robe is the right hue for a fall wedding
ceremony.
https://digi590sa.z7.web.core.windows.net/research/digi590sa-(108).html
When looking for mom of the bride dresses, firstly, consider the general gown code
on the invite.
https://je-tall-marketing-785.blr1.digitaloceanspaces.com/research/je-marketing-(110).html
Maybe she envisions everybody carrying impartial tones, or perhaps she prefers
bold and shiny.
https://digi592sa.z11.web.core.windows.net/research/digi592sa-(144).html
So, in case your children are internet hosting a black tie affair,
make certain to put on a floor-length gown—preferably in a impartial tone .
https://je-tall-marketing-818.fra1.digitaloceanspaces.com/research/je-marketing-(151).html
The evaluations are positive although appear to report you want to order a measurement up.
https://digi644sa.netlify.app/research/digi644sa-(241)
We love spring colors like blush, gold, pale green, and blue
along with floral prints for mom of the bride dresses for spring weddings.
https://je-tall-marketing-771.lon1.digitaloceanspaces.com/research/je-marketing-(480).html
The subsequent factor you have to contemplate when buying around for
dresses is the shape of the dress.
https://je-tall-marketing-789.tor1.digitaloceanspaces.com/research/je-marketing-(171).html
Go for prints that speak to your marriage ceremony location,
and most significantly, her personal fashion.
https://digi644sa.netlify.app/research/digi644sa-(144)
Light, sunny, and often stuffed with flowers, and so they usually use pastel colors impressed by
springtime blooms.
https://digi590sa.z7.web.core.windows.net/research/digi590sa-(92).html
The form of your dress can hide every little thing from
a small bust to giant hips.
https://je-tall-marketing-788.lon1.digitaloceanspaces.com/research/je-marketing-(207).html
Most important factor is that you’re comfortable and not going to over warmth.
https://je-tall-marketing-765.blr1.digitaloceanspaces.com/research/je-marketing-(419).html
Current popular developments characteristic lace, prints, stylish empire waistlines
and jackets.
https://jekyll.s3.us-east-005.backblazeb2.com/20250729-3/research/je-marketing-(302).html
This mother of the bride wore a white tunic and skirt for a boho-chic
ensemble.
https://je-tall-marketing-775.tor1.digitaloceanspaces.com/research/je-marketing-(408).html
Talk to your daughter concerning the aesthetic she envisions for her marriage ceremony to help slender down your options.
https://digi596sa.z44.web.core.windows.net/research/digi596sa-(465).html
Mother of the groom clothes are down to non-public alternative
on the day.
https://digi596sa.z44.web.core.windows.net/research/digi596sa-(212).html
Fall and winter weddings name for chic muted tones like silvery gray.
https://je-tall-marketing-809.lon1.digitaloceanspaces.com/research/je-marketing-(396).html
"I wanted my ladies to have enjoyable," the bride mentioned of the choice.
https://digi596sa.z44.web.core.windows.net/research/digi596sa-(285).html
Give them glitz and glam on this allover sequin stunner.
https://digi636sa.netlify.app/research/digi636sa-(490)
Sweet and complicated, this gown wows with its daring tone and traditional silhouette.
https://je-tall-marketing-816.blr1.digitaloceanspaces.com/research/je-marketing-(479).html
Another costume with ruching for you as I assume ruched types are so
flattering.
https://digi596sa.z44.web.core.windows.net/research/digi596sa-(419).html
If there was a value for the hottest mother-of-the-bride dress, we might happily give it to this one.
https://digi644sa.netlify.app/research/digi644sa-(443)
Gone are the days when moms of the bride
have been anticipated to put on matronly attire in washed-out shades of
pastels or beige.
https://digi589sa.z29.web.core.windows.net/research/digi589sa-(162).html
Much just like the mother of the groom, step-mothers of each the
bride or groom should follow the lead of the mom of
the bride.
https://je-tall-marketing-818.fra1.digitaloceanspaces.com/research/je-marketing-(26).html
Also, a lace shirt and fishtail skirt is a stylish possibility
that has “elegance” weaved into its seams.
https://digi642sa.netlify.app/research/digi642sa-(87)
It’s usually widespread follow to avoid sporting white,
ivory or cream.
https://digi592sa.z11.web.core.windows.net/research/digi592sa-(416).html
On the other hand, If you may be curvy or apple-shaped, versatile costume styles like a-line and empire waist
will work wonders for you.
https://je-tall-marketing-773.blr1.digitaloceanspaces.com/research/je-marketing-(279).html
The straps and sleeves you choose on your gown will
affect the neckline and shape of your gown.
https://je-tall-marketing-804.tor1.digitaloceanspaces.com/research/je-marketing-(209).html
An different is to combine black with one other color, which might look very chic.
https://je-sf-tall-marketing-716.b-cdn.net/research/je-marketing-(197).html
The champagne colored ankle-length wrap costume
seems stunning on this mom of the bride.
https://jekyll.s3.us-east-005.backblazeb2.com/20250729-8/research/je-marketing-(15).html
Use these as assertion pieces, maybe in a brighter color than the rest of the outfit.